This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Fold (-a >> b) and/or/xor (~a >> b) into (-a and/or/xor ~a) >> b tests
ClosedPublic

Authored by kitaisreal on Aug 7 2023, 8:19 AM.

Diff Detail

Unit TestsFailed

Event Timeline

kitaisreal created this revision.Aug 7 2023, 8:19 AM
kitaisreal requested review of this revision.Aug 7 2023, 8:19 AM

Updated tests.

kitaisreal retitled this revision from [InstCombine] Fold (-a >> b) and/or (~a >> b) into (-a and/or ~a) >> b tests to [InstCombine] Fold (-a >> b) and/or/xor (~a >> b) into (-a and/or/xor ~a) >> b tests.Aug 12 2023, 8:04 AM

Updated tests.

Updated tests.

nikic added inline comments.Aug 14 2023, 3:13 AM
llvm/test/Transforms/InstCombine/binop-and-shifts.ll
568

All of these tests have ashr(xor) rather than xor(ashr) as the input. However, the latter is what it gets canonicalized to. It would be better to directly use the latter form, so it's clearer what the transform operates on.

We should also adjust the proofs accordingly, e.g. https://alive2.llvm.org/ce/z/Dds-Nw has the xor in the position the transform looks for it.

902

I think this could use two more negative tests:

  • Something other than -1 as the xor constant.
  • A binop for which this is not valid, e.g. add instead of and/or/xor.

Updated tests.

kitaisreal marked 2 inline comments as done.Aug 14 2023, 8:07 AM

@nikic I updated tests could you please accept this and D157290 ?

This revision is now accepted and ready to land.Aug 16 2023, 6:08 AM
This revision was landed with ongoing or failed builds.Aug 21 2023, 2:50 AM
This revision was automatically updated to reflect the committed changes.