[InstCombine] Fix bug in canonicalization of Pow2 Tests (From: D152673)
authorNoah Goldstein <goldstein.w.n@gmail.com>
Sun, 23 Jul 2023 16:26:20 +0000 (11:26 -0500)
committerNoah Goldstein <goldstein.w.n@gmail.com>
Sun, 23 Jul 2023 16:57:30 +0000 (11:57 -0500)
commitee50c09117a54fe1ff66603ef21ba6afe07b8b53
treebc1b2e98ace7bcddaf583c571890b59c65009568
parent6edc9a766213eed783e0b6dc5e2539ad925398f9
[InstCombine] Fix bug in canonicalization of Pow2 Tests (From: D152673)

D152673 Incorrectly didn't account for operand position in the `icmp`,
i.e it treated `icmp uge x, y` the same as `icmp uge y, x` which is
incorrect:
https://reviews.llvm.org/rG142f7448e770f25b774b058a7eab1f107c4daad9

The fix takes operand position into account. The new tests
exhaustively cover all operand positions for `ule`, `uge`, `ult`,
`ugt` (the set of predicates) and all transform verify with the new
commit.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D156058
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/ispow2.ll