cbergst...@pathscale.com asks for the compilation options that I used in my report of floating-point test failures of the new opencc version 4.2.4 in the features-1.2.1 tests. Here is what I used:
opencc -g -O2 I just reran the tests with multiple optimization levels on IA-32: % foreach f ( "" -g -O1 -O2 -O3 -Ofast ) foreach? echo ===== $f ; opencc $f inf.c && ./a.out | grep WRONG foreach? end ===== (-Inf > 0.0): WRONG (-Inf >= 0.0): WRONG (0.0 <= -Inf): WRONG (0.0 < -Inf): WRONG ===== -g ===== -O1 ===== -O2 (-Inf > 0.0): WRONG (-Inf >= 0.0): WRONG (0.0 <= -Inf): WRONG (0.0 < -Inf): WRONG ===== -O3 (-Inf > 0.0): WRONG (-Inf >= 0.0): WRONG (0.0 <= -Inf): WRONG (0.0 < -Inf): WRONG ===== -Ofast !IsNaN(Inf - Inf): WRONG !IsNaN(Inf - Inf): WRONG !IsNaN(Inf - Inf): WRONG Thus, behavior is correct only with -g or -O1. All others produce errors, and -Ofast produces different errors than the others. For the NaN tests, I get ===== ===== -g ===== -O1 ===== -O2 ===== -O3 ===== -Ofast (NaN == NaN): WRONG (NaN <= NaN): WRONG (NaN >= NaN): WRONG (NaN == 0.0): WRONG (NaN <= 0.0): WRONG (NaN >= 0.0): WRONG (0.0 == NaN): WRONG (0.0 <= NaN): WRONG (0.0 >= NaN): WRONG (NaN == NaN): WRONG (NaN <= NaN): WRONG (NaN >= NaN): WRONG (NaN == 0.0): WRONG (NaN <= 0.0): WRONG (NaN >= 0.0): WRONG (0.0 == NaN): WRONG (0.0 <= NaN): WRONG (0.0 >= NaN): WRONG (NaN == NaN): WRONG (NaN <= NaN): WRONG (NaN >= NaN): WRONG (NaN == 0.0): WRONG (NaN <= 0.0): WRONG (NaN >= 0.0): WRONG (0.0 == NaN): WRONG (0.0 <= NaN): WRONG (0.0 >= NaN): WRONG A check of the generated code from -O1 and -Ofast shows the problem: the correctly working code uses a run-time comparison, but the the code from -Ofast has no comparisons, and that is ALWAYS WRONG behavior for floating-point arithmetic if operands can be NaNs (which should always be assumed, unless both are finite compile-time constants). The signed zero tests pass with all six optimization choices on IA-32. The same experiment on AMD64 produced this output: ===== (-Inf > 0.0): WRONG (-Inf >= 0.0): WRONG (0.0 <= -Inf): WRONG (0.0 < -Inf): WRONG ===== -g ===== -O1 ===== -O2 (-Inf > 0.0): WRONG (-Inf >= 0.0): WRONG (0.0 <= -Inf): WRONG (0.0 < -Inf): WRONG ===== -O3 (-Inf > 0.0): WRONG (-Inf >= 0.0): WRONG (0.0 <= -Inf): WRONG (0.0 < -Inf): WRONG ===== -Ofast !IsNaN(Inf - Inf): WRONG !IsNaN(Inf - Inf): WRONG !IsNaN(Inf - Inf): WRONG For the NaN tests, I get: ===== ===== -g ===== -O1 ===== -O2 ===== -O3 ===== -Ofast (NaN == NaN): WRONG (NaN <= NaN): WRONG (NaN >= NaN): WRONG (NaN == 0.0): WRONG (NaN <= 0.0): WRONG (NaN >= 0.0): WRONG (0.0 == NaN): WRONG (0.0 <= NaN): WRONG (0.0 >= NaN): WRONG (NaN == NaN): WRONG (NaN <= NaN): WRONG (NaN >= NaN): WRONG (NaN == 0.0): WRONG (NaN <= 0.0): WRONG (NaN >= 0.0): WRONG (0.0 == NaN): WRONG (0.0 <= NaN): WRONG (0.0 >= NaN): WRONG (NaN == NaN): WRONG (NaN <= NaN): WRONG (NaN >= NaN): WRONG (NaN == 0.0): WRONG (NaN <= 0.0): WRONG (NaN >= 0.0): WRONG (0.0 == NaN): WRONG (0.0 <= NaN): WRONG (0.0 >= NaN): WRONG For the signed zero test that failed on AMD64, all optimization levels produce errors: % foreach f ( "" -g -O1 -O2 -O3 -Ofast ) foreach? echo ===== $f ; opencc $f zero.c && ./a.out | grep WRONG foreach? end ===== -zero is unsigned WRONG (-0) - (+0) is unsigned WRONG (-1)*(0) is unsigned WRONG ===== -g -zero is unsigned WRONG (-0) - (+0) is unsigned WRONG (-1)*(0) is unsigned WRONG ===== -O1 -zero is unsigned WRONG (-0) - (+0) is unsigned WRONG (-1)*(0) is unsigned WRONG ===== -O2 -zero is unsigned WRONG (-0) - (+0) is unsigned WRONG (-1)*(0) is unsigned WRONG ===== -O3 -zero is unsigned WRONG (-0) - (+0) is unsigned WRONG (-1)*(0) is unsigned WRONG ===== -Ofast -zero is unsigned WRONG (-0) - (+0) is unsigned WRONG (-1)*(0) is unsigned WRONG I do not yet have the 4.2.4 compiler working on IA-64, but for the older 4.2.3 version, here is what I get on that architecture: % foreach f ( "" -g -O1 -O2 -O3 -Ofast ) foreach? echo ===== $f ; opencc $f inf.c && ./a.out | grep WRONG foreach? end ===== be(4897): unaligned access to 0x600000000003e564, ip=0x200000000010e170 be(4897): unaligned access to 0x600000000003e58c, ip=0x200000000010e170 be(4897): unaligned access to 0x600000000003e5dc, ip=0x200000000010e130 be(4897): unaligned access to 0x600000000003e5ec, ip=0x200000000010e130 be(4897): unaligned access to 0x600000000003e614, ip=0x200000000010e170 (-Inf > 0.0): WRONG (-Inf >= 0.0): WRONG (0.0 <= -Inf): WRONG (0.0 < -Inf): WRONG ===== -g be(4927): unaligned access to 0x600000000003d874, ip=0x200000000010e170 be(4927): unaligned access to 0x600000000003d89c, ip=0x200000000010e170 be(4927): unaligned access to 0x600000000003d8ec, ip=0x200000000010e130 be(4927): unaligned access to 0x600000000003d8fc, ip=0x200000000010e130 be(4927): unaligned access to 0x600000000003d924, ip=0x200000000010e170 ===== -O1 ===== -O2 (-Inf > 0.0): WRONG (-Inf >= 0.0): WRONG (0.0 <= -Inf): WRONG (0.0 < -Inf): WRONG ===== -O3 be(5030): unaligned access to 0x600000000003f984, ip=0x200000000010e170 be(5030): unaligned access to 0x600000000003f9ac, ip=0x200000000010e170 be(5030): unaligned access to 0x600000000003f9fc, ip=0x200000000010e130 be(5030): unaligned access to 0x600000000003fa0c, ip=0x200000000010e130 be(5030): unaligned access to 0x600000000003fa34, ip=0x200000000010e170 !IsNaN(Inf - Inf): WRONG !IsNaN(Inf - Inf): WRONG (-Inf > 0.0): WRONG (-Inf >= 0.0): WRONG (0.0 <= -Inf): WRONG (0.0 < -Inf): WRONG !IsNaN(Inf - Inf): WRONG ===== -Ofast be(5080): unaligned access to 0x600000000003e694, ip=0x200000000010e170 be(5080): unaligned access to 0x600000000003e6bc, ip=0x200000000010e170 be(5080): unaligned access to 0x600000000003e70c, ip=0x200000000010e130 be(5080): unaligned access to 0x600000000003e71c, ip=0x200000000010e130 be(5080): unaligned access to 0x600000000003e744, ip=0x200000000010e170 !IsNaN(Inf - Inf): WRONG !IsNaN(Inf - Inf): WRONG !IsNaN(Inf - Inf): WRONG % foreach f ( "" -g -O1 -O2 -O3 -Ofast ) foreach? echo ===== $f ; opencc $f zero.c && ./a.out | grep WRONG foreach? end ===== be(5144): unaligned access to 0x600000000003e564, ip=0x200000000010e170 be(5144): unaligned access to 0x600000000003e58c, ip=0x200000000010e170 be(5144): unaligned access to 0x600000000003e5dc, ip=0x200000000010e130 be(5144): unaligned access to 0x600000000003e5ec, ip=0x200000000010e130 be(5144): unaligned access to 0x600000000003e614, ip=0x200000000010e170 +zero is signed WRONG -zero is unsigned WRONG 0 - 0 is signed WRONG (-0) - (+0) is unsigned WRONG (+1)*(0) is signed WRONG (-1)*(0) is unsigned WRONG ===== -g -zero is unsigned WRONG (-0) - (+0) is unsigned WRONG (-1)*(0) is unsigned WRONG ===== -O1 -zero is unsigned WRONG (-0) - (+0) is unsigned WRONG (-1)*(0) is unsigned WRONG ===== -O2 +zero is signed WRONG -zero is unsigned WRONG 0 - 0 is signed WRONG (-0) - (+0) is unsigned WRONG (+1)*(0) is signed WRONG (-1)*(0) is unsigned WRONG ===== -O3 be(5276): unaligned access to 0x600000000003f984, ip=0x200000000010e170 be(5276): unaligned access to 0x600000000003f9ac, ip=0x200000000010e170 be(5276): unaligned access to 0x600000000003f9fc, ip=0x200000000010e130 be(5276): unaligned access to 0x600000000003fa0c, ip=0x200000000010e130 be(5276): unaligned access to 0x600000000003fa34, ip=0x200000000010e170 +zero is signed WRONG -zero is unsigned WRONG 0 - 0 is signed WRONG (-0) - (+0) is unsigned WRONG (+1)*(0) is signed WRONG (-1)*(0) is unsigned WRONG ===== -Ofast -zero is unsigned WRONG (-0) - (+0) is unsigned WRONG (-1)*(0) is unsigned WRONG % foreach f ( "" -g -O1 -O2 -O3 -Ofast ) foreach? echo ===== $f ; opencc $f nan.c && ./a.out | grep WRONG foreach? end ===== be(5389): unaligned access to 0x600000000003e564, ip=0x200000000010e170 be(5389): unaligned access to 0x600000000003e58c, ip=0x200000000010e170 be(5389): unaligned access to 0x600000000003e5dc, ip=0x200000000010e130 be(5389): unaligned access to 0x600000000003e5ec, ip=0x200000000010e130 be(5389): unaligned access to 0x600000000003e614, ip=0x200000000010e170 ===== -g ===== -O1 ===== -O2 ===== -O3 be(5522): unaligned access to 0x600000000003f984, ip=0x200000000010e170 be(5522): unaligned access to 0x600000000003f9ac, ip=0x200000000010e170 be(5522): unaligned access to 0x600000000003f9fc, ip=0x200000000010e130 be(5522): unaligned access to 0x600000000003fa0c, ip=0x200000000010e130 be(5522): unaligned access to 0x600000000003fa34, ip=0x200000000010e170 ===== -Ofast (NaN == NaN): WRONG (NaN <= NaN): WRONG (NaN >= NaN): WRONG (NaN == 0.0): WRONG (NaN <= 0.0): WRONG (NaN >= 0.0): WRONG (0.0 == NaN): WRONG (0.0 <= NaN): WRONG (0.0 >= NaN): WRONG (NaN == NaN): WRONG (NaN <= NaN): WRONG (NaN >= NaN): WRONG (NaN == 0.0): WRONG (NaN <= 0.0): WRONG (NaN >= 0.0): WRONG (0.0 == NaN): WRONG (0.0 <= NaN): WRONG (0.0 >= NaN): WRONG (NaN == NaN): WRONG (NaN <= NaN): WRONG (NaN >= NaN): WRONG (NaN == 0.0): WRONG (NaN <= 0.0): WRONG (NaN >= 0.0): WRONG (0.0 == NaN): WRONG (0.0 <= NaN): WRONG (0.0 >= NaN): WRONG The many unaligned access errors are bothersome, and they also produce reports in /var/log/messages. ------------------------------------------------------------------------------- - Nelson H. F. Beebe Tel: +1 801 581 5254 - - University of Utah FAX: +1 801 581 4148 - - Department of Mathematics, 110 LCB Internet e-mail: be...@math.utah.edu - - 155 S 1400 E RM 233 be...@acm.org be...@computer.org - - Salt Lake City, UT 84112-0090, USA URL: http://www.math.utah.edu/~beebe/ - ------------------------------------------------------------------------------- ------------------------------------------------------------------------------ Forrester Wave Report - Recovery time is now measured in hours and minutes not days. Key insights are discussed in the 2010 Forrester Wave Report as part of an in-depth evaluation of disaster recovery service providers. Forrester found the best-in-class provider in terms of services and vision. Read this report now! http://p.sf.net/sfu/ibm-webcastpromo _______________________________________________ Open64-devel mailing list Open64-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/open64-devel