[PATCH] D99171: [WebAssembly] Fold xor by inverting branch target
Thomas Lively via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 23 20:36:43 PDT 2021
tlively added inline comments.
================
Comment at: llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td:33
(BR_UNLESS bb_op:$dst, I32:$cond)>;
+def : Pat<(brcond (i32 (xor I32:$cond, (i32 1))), bb:$dst),
+ (BR_UNLESS bb_op:$dst, I32:$cond)>;
----------------
kripken wrote:
> samparker wrote:
> > Ah, I've remembered that I thought I should check that the incoming I32 is indeed a boolean value.
> Yes, this seems like a valid pattern for any boolean value, not just one flowing into a br? That is,
>
> bool(x) ^ 1 => !bool(x)
>
> or in wasm
>
> (i32.xor X (i32.const 1)) => (i32.eqz X)
>
Is there a good way to check for boolean values from tablegen patterns?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99171/new/
https://reviews.llvm.org/D99171
More information about the llvm-commits
mailing list