[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Jul 23 12:27:01 PDT 2003
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.99 -> 1.100
---
Log message:
InstCombine: (X ^ 4) == 8 --> X == 12
---
Diffs of the changes:
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.99 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.100
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.99 Wed Jul 23 12:02:11 2003
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Wed Jul 23 12:26:36 2003
@@ -711,7 +711,7 @@
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 @@
// 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);
}
}
More information about the llvm-commits
mailing list