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

Reid Spencer rspencer at reidspencer.com
Fri Mar 2 15:40:31 PST 2007


On Fri, 2007-03-02 at 15:35 -0800, Chris Lattner wrote:
> On Mar 2, 2007, at 3:31 PM, Reid Spencer wrote:
> 
> 
> > +  // Guard against huge trip counts. This also guards against  
> > assertions in
> > +  // APInt from the use of getZExtValue, below.
> > +  if (TripCountC->getValue().getActiveBits() > 32)
> >      return Changed; // More than 2^32 iterations???
> >
> > +  uint64_t TripCountFull = TripCountC->getZExtValue();
> > +  if (TripCountFull == 0)
> > +    return Changed; // Zero iteraitons?
> > +
> 
> Won't this still assert on 'i128 16' ?

No. getZExtValue() doesn't look at the bit width, it looks at the
precision of the value. Regardless of the bit width, if the value fits
in 64 bits, it allows it. If not, it asserts. Which is why I check
"getActiveBits() > 32" to limit trip counts to < 2^32. This makes the
getZExtValue() safe.

That precision check is another reason why I'm changing things like:

if (CI->getZExtValue() == 1)

into

if (CI->isOne())

because its cheaper :)

Reid.

> 
> -Chris




More information about the llvm-commits mailing list