https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61494
Bug ID: 61494 Summary: -fsignaling-nans not taken into account for x - 0.0 Product: gcc Version: 4.10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: vincent-gcc at vinc17 dot net Created attachment 32932 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=32932&action=edit testcase On x86_64, x - 0.0 is optimized to x in the asm code when compiling with -O -fsignaling-nans. This yields an incorrect behavior when x is a signaling NaN. Note that -fdump-tree-all shows that -fsignaling-nans is taken into account when the usual optimization is considered; even transf.c.170t.optimized still has "_2 = x_1(D) - 0.0;" as expected (I suppose). On PowerPC, the same x - 0.0 optimization is done with GCC 4.7.2 at least. I've attached a program that triggers the bug (it also does other tests). $ gcc -O transf.c -o transf -fsignaling-nans -lm $ ./transf 0x7ff0000000000001 x = [0x7ff0000000000001] = nan (signaling) Error for x_sub_zero in FE_TONEAREST: y0 = [0x7ff0000000000001] = nan (signaling) y1 = [0x7ff8000000000001] = nan Error for x_sub_zero in FE_TOWARDZERO: y0 = [0x7ff0000000000001] = nan (signaling) y1 = [0x7ff8000000000001] = nan Error for x_sub_zero in FE_DOWNWARD: y0 = [0x7ff0000000000001] = nan (signaling) y1 = [0x7ff8000000000001] = nan Error for x_sub_zero in FE_UPWARD: y0 = [0x7ff0000000000001] = nan (signaling) y1 = [0x7ff8000000000001] = nan