[llvm] [InstCombine] fold `(a == c && b != c) || (a != c && b == c))` to `(a == c) == (b != c)` (PR #94915)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 21 15:03:13 PDT 2024


================
@@ -3476,7 +3469,7 @@ Instruction *InstCombinerImpl::visitOr(BinaryOperator &I) {
   if (Instruction *X = foldComplexAndOrPatterns(I, Builder))
     return X;
 
-  // (A == c & B != d) | (A != c & B == d)) -> (A == c) | (B == d)
+  // (A == c & B != d) | (A != c & B == d)) -> (A == c) ^ (B == d)
----------------
goldsteinn wrote:

Also, I guess can you generalize the comment, its really '(A & B) | (C & D) where A == ~C && B == ~D or A == ~D and B == ~D'

Finally, I think you can remove: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp#L1843 w/ this patch.

https://github.com/llvm/llvm-project/pull/94915


More information about the llvm-commits mailing list