[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc
Subject:    Re: Handling NaNs in FP comparisons
From:       Richard Henderson <rth () redhat ! com>
Date:       2010-09-30 0:23:57
Message-ID: 4CA3D89D.5060300 () redhat ! com
[Download RAW message or body]

On 09/29/2010 04:31 PM, Michael Eager wrote:
> float a = 1.0, b = 2.0, x = NaN;
> (a < b) generates the same condition flags as (a < x).
...
> Are there other processors which do this?  How do they
> handle generating IEEE std compliant code?

It looks like there is a bunch of code under config
that's conditionalized on flag_finite_math_only,
which disables support for NaN and Inf.

At a glance, rs6000_generate_compare may be relevant.

> 
> A related problem is that CSE will optimize FP comparisons
> and garble the result.  (This doesn't happen with soft-fp.)
> 
>   int r = 0, s = 0;
>   float a = 1.0, x = NaN;
> 
>   r = (a <= x);
>   s = (a > x);
> 
> should result in r == s == 0.  CSE translates this (more
> or less) into
> 
>   r = (a <= x);
>   s = !r;
> 
> Is there a way to prevent CSE from optimizing FP comparisons?

Add the missing check vs HONOR_NANS.  This is clearly a bug.


r~
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic