[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu May 5 21:53:34 PDT 2005



Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.338 -> 1.339
---
Log message:

Teach instcombine propagate zeroness through shl instructions, implementing
and.ll:test31


---
Diffs of the changes:  (+4 -8)

 InstructionCombining.cpp |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.338 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.339
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.338	Thu May  5 23:18:52 2005
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Thu May  5 23:53:20 2005
@@ -1361,14 +1361,10 @@
       break;
     }
     case Instruction::Shl:
-      // (shl X, C1) & C2 == 0   iff  (-1 << C1) & C2 == 0
-      if (ConstantUInt *SA = dyn_cast<ConstantUInt>(I->getOperand(1))) {
-        Constant *C1 = ConstantIntegral::getAllOnesValue(I->getType());
-        C1 = ConstantExpr::getShl(C1, SA);
-        C1 = ConstantExpr::getAnd(C1, Mask);
-        if (C1->isNullValue())
-          return true;
-      }
+      // (shl X, C1) & C2 == 0   iff   (X & C2 >>u C1) == 0
+      if (ConstantUInt *SA = dyn_cast<ConstantUInt>(I->getOperand(1)))
+        return MaskedValueIsZero(I->getOperand(0),
+                      cast<ConstantIntegral>(ConstantExpr::getUShr(Mask, SA)));
       break;
     case Instruction::Shr:
       // (ushr X, C1) & C2 == 0   iff  (-1 >> C1) & C2 == 0






More information about the llvm-commits mailing list