[LLVMdev] Loop elimination with floating point counter.

Owen Anderson resistor at mac.com
Thu Jan 8 16:45:27 PST 2009


I assume it checks that the end condition and the increment can both  
be represented precisely with integer types.

--Owen

On Jan 8, 2009, at 9:49 AM, Martin Geisse wrote:

> Isn't "simplifying" the loop index to an integer also dependent on
> precision issues? The following loop is infinite:
>
> for (float i=0.0; i<...; i+=1.0) {}
>
> where ... is a large "integral" float literal, e.g. 2^40. At some
> point, adding 1.0 to the loop index would not cause any changes
> because of precision issues. However, if the float type is replaced
> by some sufficiently large integer type, the loop terminates.
>
> The necessary reasoning may be simpler though.
>
> Greetings,
> Martin Geisse
>
> On Jan 8, 2009, at 6:34 PM, Owen Anderson wrote:
>
>> It's because with 1.0f, the loop index is simplified into an integer.
>> With 1.2f, it isn't.  The loop deletion pass is dependent on the loop
>> analyses being able to determine that the loop is finite, which they
>> don't attempt to do for loops with floating point indices.   
>> Attempting
>> to do so would require additional reasoning about floating point
>> precision issues.
>>
>> --Owen
>>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list