Package: gcc-4.4 Version: 4.4.4-2
----- Forwarded message from Carlos O'Donell <car...@systemhalted.org> ----- Date: Sat, 22 May 2010 22:58:18 -0400 From: Carlos O'Donell <car...@systemhalted.org> To: John David Anglin <dave.ang...@nrc-cnrc.gc.ca>, Debian HPPA Port List <debian-h...@lists.debian.org>, libc-po...@sourceware.org Subject: Test tstdiomisc fails when multiplication of NAN by -1 results in NAN again. Dave, The following testcase is an example of code used in a glibc testcase. I'm trying hard to shake out the bugs in the glibc testsuite for debian, and one testsuite failure looks like a compiler issue. The expected behaviour is for the testcase to print the raw IEEE754 value of -NAN. The observed behaviour, when -DALT is on the command line, is that the testcase prints the incorrect raw value e.g. NAN. GCC 4.4.3 in debian doesn't compile this code correctly. Could you have a loot at my analysis and tell me if you have seen this before? cat >> tst-mul-nan.c <<EOF #include <stdio.h> #include <math.h> #ifdef ALT volatile double nanval; #else #define nanval NAN #endif int main () { #ifdef ALT nanval = NAN; #endif printf ("0x%llx\n", -nanval); return 0; } EOF gcc -g3 -O0 -save-temps -o test-mul-nan-OK test-mul-nan.c; ./test-mul-nan-OK 0xfff7ffffffffffff This is the correct result e.g. -NAN. In the correct case the compiler has already computer -NAN and it's loaded directly from the local symbol e.g. .LC1: .word -524289 .word -1 This is the case that is not working correctly: gcc -g3 -O0 -save-temps -DALT -o test-mul-nan-NG test-mul-nan.c; ./test-mul-nan-NG 0x7ff7ffffffffffff That result is not -NAN, it is NAN. This is incorrect. In the incorrect compilation the compiler loads NAN from a local constant: .LC0: .word 2146959359 .word -1 This is 0x7ff7ffffffffffff e.g. NAN. Then it loads something which I assume *should* be -1, but isn't: .LC2: .word -1074790400 .word 0 What is this value, it's 0xbff0000000000000 e.g. -1.875. Should it be 0xbf80000000000000 e.g. -1.0 exactly, but it's not? Is this a mistake? In the incorrect case the compiler tries to multiply this value by NAN to get a result of -NAN. addil LR'nanval-$global$,%r27 copy %r1,%r19 ldo RR'nanval-$global$(%r19),%r19 fldds 0(%r19),%fr23 ldil LR'.LC2,%r19 ldo RR'.LC2(%r19),%r19 fldds 0(%r19),%fr22 fmpy,dbl %fr23,%fr22,%fr22 It seems like it should work (even if fr22 is -1.875), since the sign of the output NAN is the XOR of the signs of the inputs, therefore "- XOR + = -" and the the result should be -NAN, but it's not, it's NAN? Why? PA-RISC 2.0 Architecture, Floating Coprocessor 8-23 "Operations With NaNs", and 8-24 "Sign Bit" can be referenced for information on NANs. After the multiplication fr22 still contains NAN, and that is what is printed instead of the expected result of -NAN. Any idea what is going on here? Thanks for your help. Cheers, Carlos. ----- End forwarded message ----- -- To UNSUBSCRIBE, email to debian-gcc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20100523164117.ga13...@scru.org