[llvm-commits] [llvm] r85478 - /llvm/trunk/lib/Analysis/MemoryBuiltins.cpp

Duncan Sands baldrick at free.fr
Fri Oct 30 00:59:05 PDT 2009


Hi Victor,

> +      unsigned Op1BitWidth = Op1->getType()->getPrimitiveSizeInBits();

you could also get the constant int as an APInt and use the getBitWidth
method.

> +      // check for overflow
> +      if (Op1Int->getZExtValue() > Op1BitWidth)
> +        return NULL;

This will cause an assertion failure if Op1Int's value does not fit
in 64 bits.

> +
> +      Value* Op1Pow = ConstantInt::get(Context,
> +                            APInt(Op1BitWidth, 1, false) << 
> Op1Int->getValue());

The APInt class has a "set" method that allows you to set a
particular bit.  I think that would be better.

Ciao,

Duncan.



More information about the llvm-commits mailing list