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

Zhou Sheng zhousheng00 at gmail.com
Wed Mar 28 02:19:18 PDT 2007



Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.702 -> 1.703
---
Log message:

1. Make more use of getLowBitsSet/getHighBitsSet.
2. Make the APInt value do the zext/trunc stuff instead of using 
   ConstantExpr::getZExt().


---
Diffs of the changes:  (+3 -5)

 InstructionCombining.cpp |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.702 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.703
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.702	Wed Mar 28 00:15:57 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Wed Mar 28 04:19:01 2007
@@ -6304,8 +6304,7 @@
       case Instruction::ZExt: {
         // We need to emit an AND to clear the high bits.
         assert(SrcBitSize < DestBitSize && "Not a zext?");
-        Constant *C = ConstantInt::get(APInt::getAllOnesValue(SrcBitSize));
-        C = ConstantExpr::getZExt(C, DestTy);
+        Constant *C = ConstantInt::get(APInt::getLowBitsSet(DestBitSize, SrcBitSize));
         return BinaryOperator::createAnd(Res, C);
       }
       case Instruction::SExt:
@@ -6487,8 +6486,7 @@
         unsigned ShAmt = ShAmtV->getZExtValue();
         
         // Get a mask for the bits shifting in.
-        APInt Mask(APInt::getAllOnesValue(SrcBitWidth).lshr(
-                     SrcBitWidth-ShAmt).shl(DestBitWidth));
+        APInt Mask(APInt::getLowBitsSet(SrcBitWidth, ShAmt).shl(DestBitWidth));
         Value* SrcIOp0 = SrcI->getOperand(0);
         if (SrcI->hasOneUse() && MaskedValueIsZero(SrcIOp0, Mask)) {
           if (ShAmt >= DestBitWidth)        // All zeros.
@@ -6547,7 +6545,7 @@
       // If we're actually extending zero bits and the trunc is a no-op
       if (MidSize < DstSize && SrcSize == DstSize) {
         // Replace both of the casts with an And of the type mask.
-        APInt AndValue(APInt::getAllOnesValue(MidSize).zext(SrcSize));
+        APInt AndValue(APInt::getLowBitsSet(SrcSize, MidSize));
         Constant *AndConst = ConstantInt::get(AndValue);
         Instruction *And = 
           BinaryOperator::createAnd(CSrc->getOperand(0), AndConst);






More information about the llvm-commits mailing list