[InstCombine] enhance bitwise select matching
authorSanjay Patel <spatel@rotateright.com>
Tue, 23 Nov 2021 14:50:24 +0000 (09:50 -0500)
committerSanjay Patel <spatel@rotateright.com>
Tue, 23 Nov 2021 14:57:44 +0000 (09:57 -0500)
commit430ad9697d143b4c408acf0d0d01c17830ac2bb3
tree06c134a04bf8bbb27ac3862cd8e4cfe63255a377
parente6cd157407a24f7be1c15dbf949bac98400ff96d
[InstCombine] enhance bitwise select matching

I noticed that adding a seemingly unrelated fold for xor caused
regressions on similar patterns, and this is one of the
underlying causes.

This could also be a variation for code as seen in:
https://llvm.org/PR34047
...although that exact example should be fixed after:
D113035 / c36b7e21bd8f

The vector test shows that we are actually missing a potential
canonicalization for bitcast-of-sext-of-not or the inverse.
The scalar test shows that even if we had that canonicalization,
it would still be possible to see this pattern due to extra uses.

https://alive2.llvm.org/ce/z/y2BAgi
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/logical-select.ll