This folds a not (an xor -1) though a predicate_cast, so that it can be turned into a VPNOT and potentially be folded away as an "else" predicate inside a VPT block.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Target/ARM/ARMISelLowering.cpp | ||
---|---|---|
13855 | VPT predicates are only 16 bits wide, so I think we could legally apply this to any constant XOR that has the bottom 16 bits set, not just 0xFFFFFFFF. In case somebody wrote out pred ^ 0xFFFF longhand in source code, would it be better to do that? |
llvm/lib/Target/ARM/ARMISelLowering.cpp | ||
---|---|---|
13855 | Thanks for taking a look. Long story short, the rest of llvm will like to convert xor i32 x, 0xffff to xor i32 x, -1 as it represents a not and is simpler to deal with. Because we tell it that the demanded bits of a PRED_CAST are the lower bits, it will do that transform for us and here we only need to check for a full mask. There is a isBitwiseNot helper function though, which will do this for us. I'll change it to use that and add an extra test. |
llvm/test/CodeGen/Thumb2/mve-pred-constfold.ll | ||
---|---|---|
107 | (Incidentally, it's a shame this one couldn't have ended up removing the VPNOT completely and just swapping round the operands of the VPSEL!) |
Accidentally linked my commit of https://reviews.llvm.org/D92236 to this revision. Apologies.
VPT predicates are only 16 bits wide, so I think we could legally apply this to any constant XOR that has the bottom 16 bits set, not just 0xFFFFFFFF.
In case somebody wrote out pred ^ 0xFFFF longhand in source code, would it be better to do that?