Bug 20776 - FE_DOWNWARD testcase results differ in -m32 and -m64. OK or bug?
Summary: FE_DOWNWARD testcase results differ in -m32 and -m64. OK or bug?
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.4.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2005-04-05 22:26 UTC by Jon Grimm
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Target: ppc64-unknown-linux
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Jon Grimm 2005-04-05 22:26:15 UTC
Might not be a bug even, but I haven't had much luck in finding a definitive
answer.   I get different output depending on whether I compile the following
testcase as 32-bit vs 64-bit on linux-ppc64 (gcc-3.4 and gcc-4). 

include <stdio.h>
#include <fenv.h>

int main()
 int x=1023, y=1023;
 double z;

 z = (double)(x-y);
 printf ("z = %e\n", z);

 return 0;

If I compile this as '-O0 -m32' I get a result of:

 z = -0.000000e+00

But compiling for 64-bit, '-O0 -m64' I get result of:

 z = 0.000000e+00

This was noticed by someone testing linux-ppc glibc::logb(1) after having set
the rounding mode to FE_DOWNWARD and getting a -0.0 result (glibc has similar
code as testcase above).  

GCC bug vs GLIBC bug vs User Error?
Comment 1 Andrew Pinski 2005-04-05 22:37:19 UTC
-m64 makes use of fcfid while 32bit PPC uses the following construct:
        xoris r3,r3,0x8000
        lis r0,0x4330
        stw r3,-4(r1)
        lis r2,ha16(LC0)
        stw r0,-8(r1)
        lfd f0,-8(r1)
        lfs f1,lo16(LC0)(r2)
        fsub f1,f0,f1

so there is subtraction which causes the difference.

But I don't know if this is gcc problem or just an user not expecting -0.
Comment 2 David Edelsohn 2005-04-05 22:37:48 UTC
this is incorrect