[LLVMdev] scalar-evolution + indvars fail to get the loop trip count?

Eli Friedman
Tue, 09 Dec 2008 18:18:03 -0000

On Tue, Dec 9, 2008 at 1:43 AM, Sheng Zhou <zhousheng at autoesl.com>
wrote:
>> Yes, that code path will fail for this example.
>>
> Why not improve this? We can change it into :
>
> APInt ExitVal = (End + A).sdiv(A);
>
> Surely we should take care of the range of this expression, maybe need
extend the bitwidth of (End+A)

That's not quite correct for cases where End is positive.  I'm pretty
sure the correct way to deal with this is that if A is less than zero,
it should negate both End and A.

-Eli