[PATCH] Added InstCombine transform for pattern "(A ^ B) | ((~A) ^ B) -> True".

David Majnemer david.majnemer at gmail.com
Wed Jul 30 09:54:17 PDT 2014


Thinking about this with some colleagues, I'm starting to believe that this can be fixed in a more general way.

We do not optimize `(A ^ B) | ((A ^ -1) ^ B)` but we correctly optimize `(A ^ B) | ((A ^ B) ^ -1)`; this makes me think that we are looking at a bug in reassociate.

================
Comment at: lib/Analysis/InstructionSimplify.cpp:1606
@@ -1605,1 +1605,3 @@
 
+  // (A^B) | (~(A)^B) -> 1
+  if (match(Op0, m_Xor(m_Value(A), m_Value(B))) &&
----------------
This comment looks wrong, it should probably be:
  // (A ^ B) | ((~A) ^ B) = -1

http://reviews.llvm.org/D4691






More information about the llvm-commits mailing list