[llvm] [InstCombine] Fold xored one-complemented operand comparisons (PR #69882)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 13 04:41:38 PST 2023
================
@@ -7032,6 +7032,22 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
return new ICmpInst(I.getInversePredicate(), Builder.CreateAnd(X, Y),
Op1);
+ // Transform (~X ^ Y) s< ~Z --> (X ^ Y) s> Z,
+ // (~X ^ Y) s> ~Z --> (X ^ Y) s< Z,
+ // (~X ^ Y) s<= ~Z --> (X ^ Y) s>= Z,
+ // (~X ^ Y) s>= ~Z --> (X ^ Y) s<= Z,
+ // (~X ^ Y) u< ~Z --> (X ^ Y) u< Z,
+ // (~X ^ Y) u> ~Z --> (X ^ Y) u< Z,
+ // (~X ^ Y) u<= ~Z --> (X ^ Y) u>= Z,
+ // (~X ^ Y) u>= ~Z --> (X ^ Y) <= Z,
+ // (~X ^ Y) == ~Z --> (X ^ Y) != Z,
+ // and (~X ^ Y) != ~Z --> (X ^ Y) == Z,
----------------
dtcxzyw wrote:
```suggestion
// (~X ^ Y) u>= ~Z --> (X ^ Y) u<= Z,
// (~X ^ Y) == ~Z --> (X ^ Y) == Z,
// and (~X ^ Y) != ~Z --> (X ^ Y) != Z,
```
https://github.com/llvm/llvm-project/pull/69882
More information about the llvm-commits
mailing list