public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/53134] New: Request for option to disable excess precision on i387
@ 2012-04-27  4:00 bugdal at aerifal dot cx
  2012-04-27  5:05 ` [Bug c/53134] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: bugdal at aerifal dot cx @ 2012-04-27  4:00 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53134

             Bug #: 53134
           Summary: Request for option to disable excess precision on i387
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: bugdal@aerifal.cx


Would it be possible to add to gcc an option to fully disable excess floating
point precision on i387? Basically it would work like this: any function
performing floating point arithmetic would be responsible for reading the
floating point control word, changing the precision to the right value for the
nominal type of the expression being evaluated, and restoring it afterwards
(before returning or making calls to any other function, to maintain
compatibility with code not compiled with this option).

Since even with the precision mode set correctly the exponent range of 387 fpu
registers still matches that of 80-bit long double, this mode would also imply
a store/load cycle after every single floating point operation, analogous to
-ffloat-store but on each step of calculation, not only on assignments. I
realize this would incur significant performance penalty, but for users trying
to obtain exact, reproducible, floating point results correctly rounded for the
type being used, it would be very useful. If the load/store cycle (stronger
version of -ffloat-store) were a separate option, the performance impact would
actually be extremely minimal when that part was turned off and only the
precision mode setting was turned on.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/53134] Request for option to disable excess precision on i387
  2012-04-27  4:00 [Bug c/53134] New: Request for option to disable excess precision on i387 bugdal at aerifal dot cx
@ 2012-04-27  5:05 ` pinskia at gcc dot gnu.org
  2012-04-27  5:25 ` bugdal at aerifal dot cx
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-04-27  5:05 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53134

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-04-27 05:04:21 UTC ---
Have you tried -fexcess-precision=standard ?


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/53134] Request for option to disable excess precision on i387
  2012-04-27  4:00 [Bug c/53134] New: Request for option to disable excess precision on i387 bugdal at aerifal dot cx
  2012-04-27  5:05 ` [Bug c/53134] " pinskia at gcc dot gnu.org
@ 2012-04-27  5:25 ` bugdal at aerifal dot cx
  2012-04-27  5:29 ` [Bug target/53134] " pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bugdal at aerifal dot cx @ 2012-04-27  5:25 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53134

--- Comment #2 from Rich Felker <bugdal at aerifal dot cx> 2012-04-27 05:24:45 UTC ---
Thanks for the tip. I was not aware of that option (it's like -ffloat-store but
also applies to casts, so it makes GCC's behavior ISO C conformant), and it
seems some attention has been paid to making it actually correct. For instance,
it disables the intrinsic sqrt function which is non-conformant with excess
precision (the result is not correctly rounded). Overall quite impressive.

With that said, it's still a bit less/different than what I'm asking for. With
-fexcess-precision=standard, GCC on 387 behaves as a standards-conformant ISO C
compiler with FLT_EVAL_METHOD=2. The option I'm asking for would make it behave
as a standards-conformant ISO C compiler with FLT_EVAL_METHOD=0, which has 100%
well-defined bit-exact behavior for all non-transcendental operations. Or,
stated differently, it would give results identical to -msse2 -mfpmath=sse but
without requiring a CPU with sse2 instruction set support.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/53134] Request for option to disable excess precision on i387
  2012-04-27  4:00 [Bug c/53134] New: Request for option to disable excess precision on i387 bugdal at aerifal dot cx
  2012-04-27  5:05 ` [Bug c/53134] " pinskia at gcc dot gnu.org
  2012-04-27  5:25 ` bugdal at aerifal dot cx
@ 2012-04-27  5:29 ` pinskia at gcc dot gnu.org
  2012-04-27 10:23 ` joseph at codesourcery dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-04-27  5:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53134

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |target

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-04-27 05:28:43 UTC ---
>without requiring a CPU with sse2 instruction set support.

What processor that is in production now that does not have SSE2?


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/53134] Request for option to disable excess precision on i387
  2012-04-27  4:00 [Bug c/53134] New: Request for option to disable excess precision on i387 bugdal at aerifal dot cx
                   ` (2 preceding siblings ...)
  2012-04-27  5:29 ` [Bug target/53134] " pinskia at gcc dot gnu.org
@ 2012-04-27 10:23 ` joseph at codesourcery dot com
  2012-04-27 10:27 ` joseph at codesourcery dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: joseph at codesourcery dot com @ 2012-04-27 10:23 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53134

--- Comment #4 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2012-04-27 10:23:42 UTC ---
On Fri, 27 Apr 2012, bugdal at aerifal dot cx wrote:

> Since even with the precision mode set correctly the exponent range of 387 fpu
> registers still matches that of 80-bit long double, this mode would also imply
> a store/load cycle after every single floating point operation, analogous to
> -ffloat-store but on each step of calculation, not only on assignments. I

I think it would also imply checks for subnormal results and fixups to 
avoid double rounding in those cases.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/53134] Request for option to disable excess precision on i387
  2012-04-27  4:00 [Bug c/53134] New: Request for option to disable excess precision on i387 bugdal at aerifal dot cx
                   ` (3 preceding siblings ...)
  2012-04-27 10:23 ` joseph at codesourcery dot com
@ 2012-04-27 10:27 ` joseph at codesourcery dot com
  2012-04-27 11:51 ` bugdal at aerifal dot cx
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: joseph at codesourcery dot com @ 2012-04-27 10:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53134

--- Comment #5 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2012-04-27 10:26:22 UTC ---
See also what I said in 
<http://gcc.gnu.org/ml/gcc-patches/2008-11/msg00105.html>:

    The option naming leaves open the possibility of other options such as
    "none" if someone wishes to implement them.  ("none" would involve the
    compiler doing mode switching and adding code to deal with extra range
    and double rounding of subnormals.  There could also be an option to
    have extra range but not precision, again with the compiler inserting
    mode switches as needed.)  I am however doubtful of the use of such
    options; this patch deals with a major area where -std=c99 fails to
    implement standard semantics in default x86 configurations, but I'd
    expect people wanting particular semantics beyond a predictable
    version of C99 would use SSE.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/53134] Request for option to disable excess precision on i387
  2012-04-27  4:00 [Bug c/53134] New: Request for option to disable excess precision on i387 bugdal at aerifal dot cx
                   ` (4 preceding siblings ...)
  2012-04-27 10:27 ` joseph at codesourcery dot com
@ 2012-04-27 11:51 ` bugdal at aerifal dot cx
  2012-04-28 10:31 ` manu at gcc dot gnu.org
  2012-04-28 23:15 ` bugdal at aerifal dot cx
  7 siblings, 0 replies; 9+ messages in thread
From: bugdal at aerifal dot cx @ 2012-04-27 11:51 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53134

--- Comment #6 from Rich Felker <bugdal at aerifal dot cx> 2012-04-27 11:51:05 UTC ---
Joseph, you're right, and I don't see any way to handle the denormal issue
without really ugly and much slower wrapper code around each op...


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/53134] Request for option to disable excess precision on i387
  2012-04-27  4:00 [Bug c/53134] New: Request for option to disable excess precision on i387 bugdal at aerifal dot cx
                   ` (5 preceding siblings ...)
  2012-04-27 11:51 ` bugdal at aerifal dot cx
@ 2012-04-28 10:31 ` manu at gcc dot gnu.org
  2012-04-28 23:15 ` bugdal at aerifal dot cx
  7 siblings, 0 replies; 9+ messages in thread
From: manu at gcc dot gnu.org @ 2012-04-28 10:31 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53134

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |manu at gcc dot gnu.org
         Resolution|                            |WONTFIX

--- Comment #7 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-04-28 10:30:57 UTC ---
So I guess WONTFIX then.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/53134] Request for option to disable excess precision on i387
  2012-04-27  4:00 [Bug c/53134] New: Request for option to disable excess precision on i387 bugdal at aerifal dot cx
                   ` (6 preceding siblings ...)
  2012-04-28 10:31 ` manu at gcc dot gnu.org
@ 2012-04-28 23:15 ` bugdal at aerifal dot cx
  7 siblings, 0 replies; 9+ messages in thread
From: bugdal at aerifal dot cx @ 2012-04-28 23:15 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53134

--- Comment #8 from Rich Felker <bugdal at aerifal dot cx> 2012-04-28 23:14:57 UTC ---
I agree, sadly, that WONTFIX is probably the most appropriate action. At least,
like Andrew said, we're getting to the point where assuming it's okay to build
with -msse2 and -mfpmath=sse is reasonable.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-04-28 23:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-27  4:00 [Bug c/53134] New: Request for option to disable excess precision on i387 bugdal at aerifal dot cx
2012-04-27  5:05 ` [Bug c/53134] " pinskia at gcc dot gnu.org
2012-04-27  5:25 ` bugdal at aerifal dot cx
2012-04-27  5:29 ` [Bug target/53134] " pinskia at gcc dot gnu.org
2012-04-27 10:23 ` joseph at codesourcery dot com
2012-04-27 10:27 ` joseph at codesourcery dot com
2012-04-27 11:51 ` bugdal at aerifal dot cx
2012-04-28 10:31 ` manu at gcc dot gnu.org
2012-04-28 23:15 ` bugdal at aerifal dot cx

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).