On Mar 2, 2007, at 3:40 PM, Reid Spencer wrote:

> 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.

Ok, nifty.

> That precision check is another reason why I'm changing things like:
>
> if (CI->getZExtValue() == 1)
>
> into
>
> if (CI->isOne())
>
> because its cheaper :)

Woot!

-Chris
_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to