[llvm-commits] [llvm] r54786 - in /llvm/trunk: lib/Transforms/Scalar/LoopStrengthReduce.cpp test/Transforms/LoopStrengthReduce/2008-08-14-ShadowIV.ll

Evan Cheng evan.cheng at apple.com
Fri Aug 15 01:13:13 PDT 2008


Yes, the patch is not checking for overflow and mantissa bits. I've  
backed it out for now.

Evan
On Aug 14, 2008, at 9:31 PM, Eli Friedman wrote:

> This patch doesn't handle overflow correctly.
>
> Take the following, where the iteration count is very large (greater  
> than 2^32):
> unsigned y(double);
> unsigned z();
> unsigned x() {
>  unsigned x = 0;
>  for ( ; z(); x++) y(x);
> }
> The transformation is unsafe because x is supposed to overflow.
>
> or the following, where a is very large (greater than around 2^23):
> void y(float);
> unsigned x(unsigned a) {
>  unsigned i = 0;
>  for ( ; i < a; i++) y(i);
> }
> The transformation is unsafe because the float induction variable will
> eventually stop increasing.
>
> It is possible to prove this transformation safe (for example, the
> transformation is safe for 2008-08-14-ShadowIV.ll because the mantissa
> of double is greater than 32 bits and the iteration count is %n <
> 2^32), but as-is, this commit breaks correct code.
>
>
> I'm not sure if this is related to the patch, but one testcase I was
> trying that I expected to trigger the new code didn't end up
> triggering it, for reasons I haven't yet figured out:
>
> unsigned y(double);
> unsigned x(unsigned long long a) {
>  unsigned long long i = 0;
>  unsigned x = 0;
>  for ( ; i < a; x++, i++) y(x);
> }
>
> -Eli
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list