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

Chris Lattner clattner at apple.com
Sat Mar 24 16:20:26 PDT 2007


> @@ -2961,11 +2961,10 @@
>        if (CI->isAllOnesValue())              // X * -1 == 0 - X
>          return BinaryOperator::createNeg(Op0, I.getName());
>
> -      int64_t Val = (int64_t)cast<ConstantInt>(CI)->getZExtValue();
> -      if (isPowerOf2_64(Val)) {          // Replace X*(2^C) with X  
> << C
> -        uint64_t C = Log2_64(Val);
> +      APInt Val(cast<ConstantInt>(CI)->getValue());

In this case, Val is just a shorter way to refer to the APInt in CI,  
you don't ever modify Val itself.  In this case, just use a const  
reference, to avoid copying the APInt.  Likewise in many places.   
Copying an APInt is far more expensive than copying a uint64_t.

> @@ -3427,7 +3424,7 @@
>
>    if (Value *RHSNeg = dyn_castNegVal(Op1))
>      if (!isa<ConstantInt>(RHSNeg) ||
> -        cast<ConstantInt>(RHSNeg)->getSExtValue() > 0) {
> +        cast<ConstantInt>(RHSNeg)->getValue().isPositive()) {

This is a bug, you want isStrictlyPositive(), please fix ASAP.

-Chris



More information about the llvm-commits mailing list