If Y is non-zero we can simplify the ge/le -> gt/lt
(X ^ Y_NonZero) u>= X --> (X ^ Y_NonZero) u> X
(X ^ Y_NonZero) u<= X --> (X ^ Y_NonZero) u< X
(X ^ Y_NonZero) s>= X --> (X ^ Y_NonZero) s> X
(X ^ Y_NonZero) s<= X --> (X ^ Y_NonZero) s< X
Paths
| Differential D144608
[InstCombine] Add transforms for `(icmp {u|s}ge/le (xor X, Y), X)` ClosedPublic Authored by goldstein.w.n on Feb 22 2023, 5:20 PM.
Details Summary If Y is non-zero we can simplify the ge/le -> gt/lt (X ^ Y_NonZero) u>= X --> (X ^ Y_NonZero) u> X (X ^ Y_NonZero) u<= X --> (X ^ Y_NonZero) u< X (X ^ Y_NonZero) s>= X --> (X ^ Y_NonZero) s> X (X ^ Y_NonZero) s<= X --> (X ^ Y_NonZero) s< X
Diff Detail
Event TimelineComment Actions This is adding a lot of code to a function that's already too big. A helper function will make it easier to read. This seems like 2 or 3 independent patches? I just looked at the first group of 4 Alive proofs, and those seem fine.
Comment Actions
Sorry just saw this, will do so, likewise for the or patch. goldstein.w.n added a child revision: D145280: [InstCombine] Add transforms for `(icmp (xor X, Y), X)`.Mar 3 2023, 3:56 PM goldstein.w.n removed a child revision: D144609: [InstCombine] Add tests for transforming `(icmp (or X, Y), X)`; NFC. goldstein.w.n retitled this revision from [InstCombine] Add transforms for `(icmp (xor X, Y), X)` to [InstCombine] Add transforms for `(icmp {u|s}ge/le (xor X, Y), X)`.Mar 3 2023, 4:00 PM
goldstein.w.n added inline comments.
This revision is now accepted and ready to land.Mar 6 2023, 10:57 AM This revision was landed with ongoing or failed builds.Apr 17 2023, 8:39 PM Closed by commit rGa3fd060d4223: [InstCombine] Add transforms for `(icmp {u|s}ge/le (xor X, Y), X)` (authored by goldstein.w.n). · Explain Why This revision was automatically updated to reflect the committed changes. This revision is now accepted and ready to land.Apr 18 2023, 1:32 PM goldstein.w.n removed a child revision: D145280: [InstCombine] Add transforms for `(icmp (xor X, Y), X)`.May 28 2023, 2:21 PM
Revision Contents
Diff 499678 llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/icmp-of-xor-x.ll
|
Can we canonicalize the xor as operand 0?
It shouldn't make much difference on this patch, but that would make the next one smaller.