Page MenuHomePhabricator

[ARM] Turn pred_cast(xor(x, -1)) into xor(pred_cast(x), -1)

Authored by dmgreen on Nov 27 2020, 8:19 AM.



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.

Diff Detail

Event Timeline

dmgreen created this revision.Nov 27 2020, 8:19 AM
dmgreen requested review of this revision.Nov 27 2020, 8:19 AM
simon_tatham added inline comments.Nov 30 2020, 2:35 AM

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?

dmgreen added inline comments.Dec 1 2020, 12:58 AM

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.

dmgreen updated this revision to Diff 308567.Dec 1 2020, 12:59 AM

Use isBitwiseNot and add an extra test.

simon_tatham accepted this revision.Dec 1 2020, 1:49 AM
simon_tatham added inline comments.

(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!)

This revision is now accepted and ready to land.Dec 1 2020, 1:49 AM
avieira added a subscriber: avieira.

Accidentally linked my commit of to this revision. Apologies.