summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-07-23 17:26:36 +0000
committerChris Lattner <sabre@nondot.org>2003-07-23 17:26:36 +0000
commitcfbce7c8807379a82bbd7e666d14543dabaaab84 (patch)
treef906e047f9e92a9785432dc1feb6f7515bd7d921 /llvm/lib/Transforms/Scalar/InstructionCombining.cpp
parent2309b410f39aefc7cafa732d90a61e9e74b580de (diff)
downloadbcm5719-llvm-cfbce7c8807379a82bbd7e666d14543dabaaab84.tar.gz
bcm5719-llvm-cfbce7c8807379a82bbd7e666d14543dabaaab84.zip
InstCombine: (X ^ 4) == 8 --> X == 12
llvm-svn: 7260
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index d9c6ccee8d4..4e369272003 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/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);
}
}
OpenPOWER on IntegriCloud