[LLVMdev] folding x * 0 = 0

Jon Harrop jon at ffconsultancy.com
Sat Mar 6 22:11:57 PST 2010


On Friday 05 March 2010 08:36:24 Jochen Wilhelmy wrote:
> > I just wanted to point out that if x = inf the result of x * 0 is in
> > indeterminate form so reducing it to zero would give the wrong result
> > in that case.
>
> Yes, thanks for the hint, but someone else already pointed out that
> nan*0 is also not 0.
>
> I have a special application where inf and nan will not occur, therefore
> I will patch
> my local llvm to optimize floats more aggressively.
> If the result of 2.0 * 2.0 is between 3.9 and 4.1 this is sufficient for
> me if it's faster ;-)

Note that your optimizations also fail on other values such as -0.0 and not 
just infinity and NaN.

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e



More information about the llvm-dev mailing list