llvm-project/llvm/lib/Transforms
David Majnemer 42af3601c2 InstCombine: Simplify (A ^ B) or/and (A ^ B ^ C)
While we can already transform A | (A ^ B) into A | B, things get bad
once we have (A ^ B) | (A ^ B ^ Cst) because reassociation will morph
this into (A ^ B) | ((A ^ Cst) ^ B).  Our existing patterns fail once
this happens.

To fix this, we add a new pattern which looks through the tree of xor
binary operators to see that, in fact, there exists a redundant xor
operation.

What follows bellow is a correctness proof of the transform using CVC3.

$ cat t.cvc
A, B, C : BITVECTOR(64);

QUERY BVXOR(A, B) | BVXOR(BVXOR(B, C), A) = BVXOR(A, B) | C;
QUERY BVXOR(BVXOR(A, C), B) | BVXOR(A, B) = BVXOR(A, B) | C;

QUERY BVXOR(A, B) & BVXOR(BVXOR(B, C), A) = BVXOR(A, B) & ~C;
QUERY BVXOR(BVXOR(A, C), B) & BVXOR(A, B) = BVXOR(A, B) & ~C;

$ cvc3 < t.cvc
Valid.
Valid.
Valid.
Valid.

llvm-svn: 214342
2014-07-30 21:26:37 +00:00
..
Hello [CMake] Add LLVM_LINK_COMPONENTS to loadable modules, LLVMHello and BugpointPasses, on Win32. 2014-07-13 13:36:48 +00:00
IPO Fixing a few -Woverloaded-virtual warnings by exposing the hidden virtual function as well. No functional changes intended. 2014-07-30 19:23:59 +00:00
InstCombine InstCombine: Simplify (A ^ B) or/and (A ^ B ^ C) 2014-07-30 21:26:37 +00:00
Instrumentation [Debug Info] add DISubroutineType and its creation takes DITypeArray. 2014-07-28 22:24:06 +00:00
ObjCARC AA metadata refactoring (introduce AAMDNodes) 2014-07-24 12:16:19 +00:00
Scalar Fixing a few -Woverloaded-virtual warnings by exposing the hidden virtual function as well. No functional changes intended. 2014-07-30 19:23:59 +00:00
Utils SimplifyCFG: Avoid miscompilations due to removed lifetime intrinsics. 2014-07-30 21:04:00 +00:00
Vectorize SLP Vectorizer: Canonicalize tree operands of commutitive binary operands. 2014-07-30 21:07:56 +00:00
CMakeLists.txt Extracted ObjCARC.cpp into its own library libLLVMObjCARCOpts in preparation for refactoring the ARC Optimizer. 2013-01-28 01:35:51 +00:00
LLVMBuild.txt Extracted ObjCARC.cpp into its own library libLLVMObjCARCOpts in preparation for refactoring the ARC Optimizer. 2013-01-28 01:35:51 +00:00
Makefile Extracted ObjCARC.cpp into its own library libLLVMObjCARCOpts in preparation for refactoring the ARC Optimizer. 2013-01-28 01:35:51 +00:00