Bug 17614 - long double / -mfp-rounding-mode=d -mieee-with-inexact
Summary: long double / -mfp-rounding-mode=d -mieee-with-inexact
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.4.2
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-09-22 15:59 UTC by Patrick Pelissier
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: alpha-unknown-freebsd5.2.1
Target: alpha-unknown-freebsd5.2.1
Build: alpha-unknown-freebsd5.2.1
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Pelissier 2004-09-22 15:59:33 UTC
The following program:

int main()
{
  long double d, e;
  d = 1.0; while ((e = d / 2.0) != (long double) 0.0) d = e;
  return 0;
}

loops forever if it is compiled without optimization:

spe149.testdrive.hp.com> /tmp/make/bin/gcc test4.c -mfp-rounding-mode=d
-mieee-with-inexact
spe149.testdrive.hp.com> time ./a.out
^C0.405u 4.378s 0:04.79 99.5%   10+174k 0+0io 0pf+0w
spe149.testdrive.hp.com> /tmp/make/bin/gcc test4.c -mfp-rounding-mode=d
-mieee-with-inexact -O2
spe149.testdrive.hp.com> time ./a.out
0.000u 0.004s 0:00.00 0.0%      0+0k 0+0io 0pf+0w
spe149.testdrive.hp.com> /tmp/make/bin/gcc -v
Reading specs from /tmp/make/lib/gcc/alpha-unknown-freebsd5.2.1/3.4.2/specs
Configured with: ./configure --prefix=/tmp/gcc : (reconfigured) ./configure
--prefix=/tmp/gcc : (reconfigured) ./configure --prefix=/tmp/make
--enable-languages=c
Thread model: posix
gcc version 3.4.2

The same problem appears with GCC 3.3.3 [FreeBSD] 20031106
Comment 1 Andrew Pinski 2004-09-22 18:06:55 UTC
Well it should as you used -mfp-rounding-mode=d

Dynamic rounding mode. A field in the floating point control register (fpcr, see Alpha architecture 
reference manual) controls the rounding mode in effect. The C library initializes this register for 
rounding towards plus infinity. Thus, unless your program modifies the fpcr, d corresponds to round 
towards plus infinity.

Since you are rounding towards postive infinity you will never reach zero.