[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Oct 9 15:09:01 PDT 2005
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.384 -> 1.385
---
Log message:
Make MaskedValueIsZero a bit more aggressive
---
Diffs of the changes: (+9 -3)
InstructionCombining.cpp | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.384 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.385
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.384 Sun Oct 9 01:36:35 2005
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Oct 9 17:08:50 2005
@@ -404,11 +404,17 @@
switch (I->getOpcode()) {
case Instruction::And:
// (X & C1) & C2 == 0 iff C1 & C2 == 0.
- if (ConstantIntegral *CI = dyn_cast<ConstantIntegral>(I->getOperand(1)))
- if (ConstantExpr::getAnd(CI, Mask)->isNullValue())
+ if (ConstantIntegral *CI = dyn_cast<ConstantIntegral>(I->getOperand(1))) {
+ ConstantIntegral *C1C2 =
+ cast<ConstantIntegral>(ConstantExpr::getAnd(CI, Mask));
+ if (MaskedValueIsZero(I->getOperand(0), C1C2))
return true;
- break;
+ }
+ // If either the LHS or the RHS are MaskedValueIsZero, the result is zero.
+ return MaskedValueIsZero(I->getOperand(1), Mask) ||
+ MaskedValueIsZero(I->getOperand(0), Mask);
case Instruction::Or:
+ case Instruction::Xor:
// If the LHS and the RHS are MaskedValueIsZero, the result is also zero.
return MaskedValueIsZero(I->getOperand(1), Mask) &&
MaskedValueIsZero(I->getOperand(0), Mask);
More information about the llvm-commits
mailing list