[Cfp-interest] problem with fmaxmag code

Jim Thomas jaswthomas at sbcglobal.net
Tue Oct 16 16:43:23 PDT 2012


On Oct 16, 2012, at 4:20 PM, Ian McIntosh wrote:

> Would it work to just replace
> isgreaterequal(fabs(x), fabs(y))
> with
> (fabs(x) >= fabs(y))
> at least when FP_SNANS_ALWAYS_SIGNAL is defined, so the >= triggers on the signaling NaN?
> 
>= would have the undesirable effect of raising "invalid" on quiet NaN operands.

Also, >= wouldn't address the problem of returning a signaling NaN after having raised "invalid".

-Jim
> 
> - Ian McIntosh IBM Canada Lab Compiler Back End Support and Development
> 
> 
> <graycol.gif>Jim Thomas ---10/16/2012 12:03:50 AM---The sample implementations of fmax and round have similar problems. -Jim
> 
> <ecblank.gif>
> From:
> <ecblank.gif>
> Jim Thomas <jaswthomas at sbcglobal.net>
> <ecblank.gif>
> To:
> <ecblank.gif>
> CFP <cfp-interest at ucbtest.org>
> <ecblank.gif>
> Date:
> <ecblank.gif>
> 10/16/2012 12:03 AM
> <ecblank.gif>
> Subject:
> <ecblank.gif>
> Re: [Cfp-interest] problem with fmaxmag code
> <ecblank.gif>
> Sent by:
> <ecblank.gif>
> cfp-interest-bounces at oakapple.net
> 
> 
> 
> The sample implementations of fmax and round have similar problems.
> 
> -Jim
> 
> On Oct 15, 2012, at 2:38 PM, Jim Thomas wrote:
> 
> Our Part 1 draft has
> ------------------------------------------------
> 
> [3] The body of the fmaxmag function might be[1] 
> 
> 
> 
> { return (isgreaterequal(fabs(x), fabs(y)) || isnan(y)) ? x : y; }
> 
> 
> [1] This implementation does not handle signaling NaNs as required of implementations that define FP_SNANS_ALWAYS_SIGNAL.
> 
> ------------------------------------------------
> 
> isgreaterequal might or might not raise the "invalid" floating-point exception if the implementation does not define FP_SNANS_ALWAYS_SIGNAL. Suppose it does. Suppose also that same-format conversions are copy operations. Then if x is a signaling NaN, the code would raise "invalid" but return a signaling NaN, violating F.2.1[4]. A fix would be to change the code to
> 
> 
> { return canonicalize((isgreaterequal(fabs(x), fabs(y)) || isnan(y)) ? x : y); }
> 
> Then we could remove the footnote. The change would also serve to produce a canonical result.
> 
> Any better ideas?
> 
> -Jim
> _______________________________________________
> Cfp-interest mailing list
> Cfp-interest at oakapple.net
> http://mailman.oakapple.net/mailman/listinfo/cfp-interest
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20121016/c03cb3a2/attachment-0001.html 


More information about the Cfp-interest mailing list