64-bit constant folding problem

Benjamin Gamsa ben@eecg.toronto.edu
Mon Jan 31 13:22:00 GMT 2000


It seems constant folding for 64-bit targets using 64-bit constants is
improperly performed, resulting in incorrect results for constant
expressions.  The problem appears both on the AIX target whose details
are included below, and on SGI/MIPS.

Command line: 

gcc64 -v --save-temps -maix64 file.c > & file.command

file.i:

# 1 "file.c"
int main()
{
   printf("%lx\n", 0x1400000000UL / 0x80000000UL);
   return 0;
}

file.command:

Reading specs from /stumm/j/j1/khacks/tools/aix/lib/gcc-lib/rs6000-ibm-aix4.3.2.0/2.95.1/specs
gcc version 2.95.1 19990816 (release)
 /stumm/j/j1/khacks/tools/aix/lib/gcc-lib/rs6000-ibm-aix4.3.2.0/2.95.1/cpp -lang-c -v -D__GNUC__=2 -D__GNUC_MINOR__=95 -D_IBMR2 -D_POWER -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_LONG_LONG -D_IBMR2 -D_POWER -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_LONG_LONG -Asystem(unix) -Asystem(aix) -D__CHAR_UNSIGNED__ -D__64BIT__ -D_ARCH_PPC file.c file.i
GNU CPP version 2.95.1 19990816 (release)
#include "..." search starts here:
#include <...> search starts here:
 /stumm/j/j1/khacks/tools/aix/lib/gcc-lib/rs6000-ibm-aix4.3.2.0/2.95.1/../../../../rs6000-ibm-aix4.3.2.0/include
 /stumm/j/j1/khacks/tools/aix/lib/gcc-lib/rs6000-ibm-aix4.3.2.0/2.95.1/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
 /stumm/j/j1/khacks/tools/aix/lib/gcc-lib/rs6000-ibm-aix4.3.2.0/2.95.1/../../../../include/g++-3
 /usr/local/include
End of omitted list.
 /stumm/j/j1/khacks/tools/aix/lib/gcc-lib/rs6000-ibm-aix4.3.2.0/2.95.1/cc1 file.i -quiet -dumpbase file.c -maix64 -version -o file.s
GNU C version 2.95.1 19990816 (release) (rs6000-ibm-aix4.3.2.0) compiled by GNU C version 2.95.1 19990816 (release).
 as -u -a64 -mppc64 -o file.o file.s
 /stumm/j/j1/khacks/tools/aix/lib/gcc-lib/rs6000-ibm-aix4.3.2.0/2.95.1/collect2 -bpT:0x10000000 -bpD:0x20000000 -btextro -bnodelcsect -b64 /lib/crt0_64.o -L/stumm/j/j1/khacks/tools/aix/lib/gcc-lib/rs6000-ibm-aix4.3.2.0/2.95.1/aix64 -L/stumm/j/j1/khacks/tools/aix/lib/gcc-lib/rs6000-ibm-aix4.3.2.0/2.95.1 -L/stumm/j/j1/khacks/tools/aix/rs6000-ibm-aix4.3.2.0/lib/aix64 -L/stumm/j/j1/khacks/tools/aix/rs6000-ibm-aix4.3.2.0/lib -L/stumm/j/j1/khacks/tools/aix/lib/aix64 -L/stumm/j/j1/khacks/tools/aix/lib file.o /stumm/j/j1/khacks/tools/aix/lib/gcc-lib/rs6000-ibm-aix4.3.2.0/2.95.1/aix64/libgcc.a -lc /stumm/j/j1/khacks/tools/aix/lib/gcc-lib/rs6000-ibm-aix4.3.2.0/2.95.1/aix64/libgcc.a

Output from running a.out:

0

Correct output should be (using native compiler):

28

-- 
Ben Gamsa             ben@eecg.toronto.edu  -  http://www.eecg.toronto.edu/~ben
ECE/CS, University of Toronto, Toronto, Ont. CANADA,  M5S 1A4


More information about the Gcc-bugs mailing list