Pending https://github.com/WebAssembly/design/pull/481 , this is a patch implementing br_unless in LLVM and some optimizations that are significantly easier to implement using it.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
This would also be accompanied by this change: https://github.com/WebAssembly/experimental/commit/cfd8a9dab3c188f9919bd938fcfa5446711ab6fe
The test diffs in that commit also give a pretty good illustration of the effect of this patch on codegen.
As an interim solution, to let this patch move forward without waiting for the spec process, this update adds a patch to lower br_unless into br_if, reversing the condition in place if possible, or negating the condition manually if necessary.
This may also motivate adding more floating-point comparison operators, or a dedicated not operator, if br_unless itself does not advance.
Don't you want an option to disable the pass as well, so that we can let people compare the code for both easily?
lib/Target/WebAssembly/WebAssemblyInstrControl.td | ||
---|---|---|
37 | This is only I32 because that's what we lower bool to, correct? Could you add a comment explaining it? | |
lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp | ||
133–143 | && "comment" | |
153–155 | Ditto. | |
lib/Target/WebAssembly/WebAssemblyLowerBrUnless.cpp | ||
103 | Start with Inverted = true and set Inverted = false for default? |
I hadn't planned to add an option; I tend to prefer to avoid checking in command-line options for experiments.
lib/Target/WebAssembly/WebAssemblyInstrControl.td | ||
---|---|---|
37 | Correct. |
I think it would make the discussion easier if folks could try both, but the patch looks fine for now.
This is only I32 because that's what we lower bool to, correct? Could you add a comment explaining it?