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

Chris Lattner clattner at apple.com
Thu Mar 29 23:08:22 PDT 2007


On Mar 28, 2007, at 6:57 PM, Zhou Sheng wrote:

> @@ -540,8 +540,10 @@
>        if (I->getOpcode() == Instruction::Shl)
>          if ((CST = dyn_cast<ConstantInt>(I->getOperand(1)))) {
>            // The multiplier is really 1 << CST.
> -          Constant *One = ConstantInt::get(V->getType(), 1);
> -          CST = cast<ConstantInt>(ConstantExpr::getShl(One, CST));
> +          uint32_t BitWidth = cast<IntegerType>(V->getType())- 
> >getBitWidth();
> +          uint32_t CSTVal = CST->getValue().getActiveBits() > 64 ?
> +                              BitWidth : CST->getZExtValue();
> +          CST = ConstantInt::get(APInt(BitWidth, 1).shl(CSTVal));
>            return I->getOperand(0);
>          }
>      }

I don't understand the logic here for the >64 active bits case.  Is  
the idea that the operation is undefined anyway?

-Chris



More information about the llvm-commits mailing list