diff options
author | Chris Lattner <sabre@nondot.org> | 2003-07-23 17:26:36 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-07-23 17:26:36 +0000 |
commit | 00b1a7e23e7e0804be5c1195d0cdef9974043049 (patch) | |
tree | ab1f3e5019b9a21085fc495eae21e9bc59817544 /lib/Transforms | |
parent | 347319a4c90abdfa333a247f892e86497c38e7bd (diff) | |
download | external_llvm-00b1a7e23e7e0804be5c1195d0cdef9974043049.zip external_llvm-00b1a7e23e7e0804be5c1195d0cdef9974043049.tar.gz external_llvm-00b1a7e23e7e0804be5c1195d0cdef9974043049.tar.bz2 |
InstCombine: (X ^ 4) == 8 --> X == 12
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7260 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index d9c6cce..4e36927 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -711,7 +711,7 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) { return BinaryOperator::createNot(Val, I.getName()); } - // If the first operand is (and|or) with a constant, and the second + // If the first operand is (and|or|xor) with a constant, and the second // operand is a constant, simplify a bit. if (BinaryOperator *BO = dyn_cast<BinaryOperator>(Op0)) if (ConstantInt *BOC = dyn_cast<ConstantInt>(BO->getOperand(1))) @@ -725,6 +725,11 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) { // comparison can never succeed! if (!(*CI & *~*BOC)->isNullValue()) return ReplaceInstUsesWith(I, ConstantBool::get(isSetNE)); + } else if (BO->getOpcode() == Instruction::Xor) { + // For the xor case, we can always just xor the two constants + // together, potentially eliminating the explicit xor. + return BinaryOperator::create(I.getOpcode(), BO->getOperand(0), + *CI ^ *BOC); } } |