[InstCombine] Add transforms for `(icmp {u|s}ge/le (xor X, Y), X)`
authorNoah Goldstein <goldstein.w.n@gmail.com>
Tue, 18 Apr 2023 00:49:27 +0000 (19:49 -0500)
committerNoah Goldstein <goldstein.w.n@gmail.com>
Tue, 18 Apr 2023 03:39:06 +0000 (22:39 -0500)
commita3fd060d4223c6a7470554561bc479d4b8e423f4
tree6616977a82b4d0e496b76391e7e9c0f5985366f5
parent7c5cc22b55673e451b5643c3b921d1fea0a41d30
[InstCombine] Add transforms for `(icmp {u|s}ge/le (xor X, Y), X)`

If Y is non-zero we can simplify the ge/le -> gt/lt

`(X ^ Y_NonZero) u>= X` --> `(X ^ Y_NonZero) u> X`
    - https://alive2.llvm.org/ce/z/k482NQ
`(X ^ Y_NonZero) u<= X` --> `(X ^ Y_NonZero) u< X`
    - https://alive2.llvm.org/ce/z/TuUDGy
`(X ^ Y_NonZero) s>= X` --> `(X ^ Y_NonZero) s> X`
    - https://alive2.llvm.org/ce/z/vXQypR
`(X ^ Y_NonZero) s<= X` --> `(X ^ Y_NonZero) s< X    `
    - https://alive2.llvm.org/ce/z/fbUq-z

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D144608
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/icmp-of-xor-x.ll