[InstCombine] allow some commutative matches for logical-and to select fold
authorSanjay Patel <spatel@rotateright.com>
Fri, 21 Oct 2022 15:15:11 +0000 (11:15 -0400)
committerSanjay Patel <spatel@rotateright.com>
Fri, 21 Oct 2022 15:28:38 +0000 (11:28 -0400)
commitd7fecf26f42b47f5c2e7e64a2975ec0dcccd7248
tree267dea01bcb25c4afd1099f04bcefee242fcfa71
parentf6fc3e23b95ef0045d4453bd3fdddd765f29099b
[InstCombine] allow some commutative matches for logical-and to select fold

This is obviously correct for real logic instructions,
and it also works for the poison-safe variants that use
selects:
https://alive2.llvm.org/ce/z/wyHiwX

This is motivated by the lack of 'xor' folding seen in issue #58313.
This more general fold should help reduce some of those patterns,
but I'm not sure if this specific case does anything for that
particular example.
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/select-safe-transforms.ll