[InstCombine] fix overzealous assert in icmp-shr fold
authorSanjay Patel <spatel@rotateright.com>
Thu, 30 Jun 2022 10:14:30 +0000 (06:14 -0400)
committerSanjay Patel <spatel@rotateright.com>
Thu, 30 Jun 2022 10:28:48 +0000 (06:28 -0400)
commit7c4b90a98d3bcd54c21f5cac340c2310dbc37705
treedd8178d6b5e826aefa0948067eafb13ed445700e
parent0445c340ff48b9ba53e69933cef0af703bb5ea0f
[InstCombine] fix overzealous assert in icmp-shr fold

The assert was added with 0399473de886595d and is correct for that
pattern, but it is off-by-1 with the enhancement in d4f39d833332.

The transforms are still correct with the new pre-condition:
https://alive2.llvm.org/ce/z/6_6ghm
https://alive2.llvm.org/ce/z/_GTBUt

And as shown in the new test, the transform is expected with
'ult' - in that case, the icmp reduces to test if the shift
amount is 0.
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/icmp-shr.ll