public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* egcs-1.0.2 i686-pc-linux-gnu math optimization pb
@ 1998-04-07  6:54 Neal Becker
  1998-04-08  9:27 ` H.J. Lu
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Neal Becker @ 1998-04-07  6:54 UTC (permalink / raw)
  To: egcs

I have some c++ code that produces incorrect results when compiled
with -O2 or -O3 (but not -O).  It is floating-point math.  Have cases
like this been reported before?

This is egcs-1.0.2 i686-pc-linux-gnu glibc-2.0.6.

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

* Re: egcs-1.0.2 i686-pc-linux-gnu math optimization pb
  1998-04-07  6:54 egcs-1.0.2 i686-pc-linux-gnu math optimization pb Neal Becker
@ 1998-04-08  9:27 ` H.J. Lu
  1998-04-08 21:20 ` Jim Wilson
       [not found] ` <199804090012.RAA06217.cygnus.egcs@rtl.cygnus.com>
  2 siblings, 0 replies; 5+ messages in thread
From: H.J. Lu @ 1998-04-08  9:27 UTC (permalink / raw)
  To: Neal Becker; +Cc: egcs

> 
> I have some c++ code that produces incorrect results when compiled
> with -O2 or -O3 (but not -O).  It is floating-point math.  Have cases
> like this been reported before?
> 
> This is egcs-1.0.2 i686-pc-linux-gnu glibc-2.0.6.
> 

Can you post a small test case?

-- 
H.J. Lu (hjl@gnu.org)

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

* Re: egcs-1.0.2 i686-pc-linux-gnu math optimization pb
  1998-04-07  6:54 egcs-1.0.2 i686-pc-linux-gnu math optimization pb Neal Becker
  1998-04-08  9:27 ` H.J. Lu
@ 1998-04-08 21:20 ` Jim Wilson
  1998-04-11 22:11   ` Craig Burley
       [not found] ` <199804090012.RAA06217.cygnus.egcs@rtl.cygnus.com>
  2 siblings, 1 reply; 5+ messages in thread
From: Jim Wilson @ 1998-04-08 21:20 UTC (permalink / raw)
  To: Neal Becker; +Cc: egcs

	I have some c++ code that produces incorrect results when compiled
	with -O2 or -O3 (but not -O).  It is floating-point math.  Have cases
	like this been reported before?

Yes.  On the x86, registers have more (excess) precision than memory, which
means the exact result you get depends on whether a value is in a register
or in memory.  Changing the optimization options changes register allocation,
which changes which values are in memory, and hence can change the program
result.

Use of -ffloat-store solves some problems.  Writing code less sensitive to
excess precision problems solves others.  Rewriting parts of the gcc x86 port
might fix others.  Hopefully IA64 (Merced) won't have this problem.

Jim

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

* Re: egcs-1.0.2 i686-pc-linux-gnu math optimization pb
       [not found] ` <199804090012.RAA06217.cygnus.egcs@rtl.cygnus.com>
@ 1998-04-09 14:17   ` Ulrich Drepper
  0 siblings, 0 replies; 5+ messages in thread
From: Ulrich Drepper @ 1998-04-09 14:17 UTC (permalink / raw)
  To: egcs

wilson@cygnus.com (Jim Wilson) writes:

> Use of -ffloat-store solves some problems.  Writing code less sensitive to
> excess precision problems solves others.  Rewriting parts of the gcc x86 port
> might fix others.  Hopefully IA64 (Merced) won't have this problem.

If you only want 53bit precision set the FPU control word accordingly.
Richard Henderson some time ago posted here the source for a little .c
file you could use on Linux.

-- Uli
---------------.      drepper at gnu.org  ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com   `------------------------

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

* Re: egcs-1.0.2 i686-pc-linux-gnu math optimization pb
  1998-04-08 21:20 ` Jim Wilson
@ 1998-04-11 22:11   ` Craig Burley
  0 siblings, 0 replies; 5+ messages in thread
From: Craig Burley @ 1998-04-11 22:11 UTC (permalink / raw)
  To: neal, egcs

>Use of -ffloat-store solves some problems.  Writing code less sensitive to
>excess precision problems solves others.  Rewriting parts of the gcc x86 port
>might fix others.  Hopefully IA64 (Merced) won't have this problem.

I believe it's correct to also say that writing code that is
*insensitive* to excess-precision problems solves *all* the
problems.  Or, at least, I'd love to learn about counterexamples,
so I can document them in the g77 manual!

(I believe the g77 and gcc docs both have some information on
this topic already.  `-ffloat-store' is definitely not "enough"
to work around overly sensitive code, as it applies only to
variables, not expressions or subexpressions.)

        tq vm, (burley)

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

end of thread, other threads:[~1998-04-11 22:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-04-07  6:54 egcs-1.0.2 i686-pc-linux-gnu math optimization pb Neal Becker
1998-04-08  9:27 ` H.J. Lu
1998-04-08 21:20 ` Jim Wilson
1998-04-11 22:11   ` Craig Burley
     [not found] ` <199804090012.RAA06217.cygnus.egcs@rtl.cygnus.com>
1998-04-09 14:17   ` Ulrich Drepper

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).