aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-02-07 09:29:58 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2018-02-07 09:29:58 +0100
commit40ff1a2d1dd5ab23649e2df91a11534f3e654ace (patch)
tree4fc1f3a5020d94acba63a9414fcc4d840a1178d1 /gcc
parent84c71bb8ecc84f6ca5cbc56786b9ba74eb05057e (diff)
downloadgcc-40ff1a2d1dd5ab23649e2df91a11534f3e654ace.zip
gcc-40ff1a2d1dd5ab23649e2df91a11534f3e654ace.tar.gz
gcc-40ff1a2d1dd5ab23649e2df91a11534f3e654ace.tar.bz2
re PR tree-optimization/84235 (Miscompilation of floating point code by dom2)
PR tree-optimization/84235 * tree-ssa-scopedtables.c (avail_exprs_stack::simplify_binary_operation): Fir MINUS_EXPR, punt if the subtraction is performed in floating point type where NaNs are honored. For *DIV_EXPR, punt for ALL_FRACT_MODE_Ps where we can't build 1. Formatting fix. * gcc.c-torture/execute/ieee/pr84235.c: New test. From-SVN: r257437
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/ieee/pr84235.c11
-rw-r--r--gcc/tree-ssa-scopedtables.c16
4 files changed, 38 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8edc8cc..088aa47 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2018-02-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/84235
+ * tree-ssa-scopedtables.c
+ (avail_exprs_stack::simplify_binary_operation): Fir MINUS_EXPR, punt
+ if the subtraction is performed in floating point type where NaNs are
+ honored. For *DIV_EXPR, punt for ALL_FRACT_MODE_Ps where we can't
+ build 1. Formatting fix.
+
2018-02-06 Jakub Jelinek <jakub@redhat.com>
PR target/84146
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a32ef37..ac3949a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-02-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/84235
+ * gcc.c-torture/execute/ieee/pr84235.c: New test.
+
2018-02-07 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR testsuite/84243
diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/pr84235.c b/gcc/testsuite/gcc.c-torture/execute/ieee/pr84235.c
new file mode 100644
index 0000000..479b2b0
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/ieee/pr84235.c
@@ -0,0 +1,11 @@
+/* PR tree-optimization/84235 */
+
+int
+main ()
+{
+ double d = 1.0 / 0.0;
+ _Bool b = d == d && (d - d) != (d - d);
+ if (!b)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/tree-ssa-scopedtables.c b/gcc/tree-ssa-scopedtables.c
index 47cca78..2a40fda 100644
--- a/gcc/tree-ssa-scopedtables.c
+++ b/gcc/tree-ssa-scopedtables.c
@@ -182,8 +182,15 @@ avail_exprs_stack::simplify_binary_operation (gimple *stmt,
case BIT_AND_EXPR:
return gimple_assign_rhs1 (stmt);
- case BIT_XOR_EXPR:
case MINUS_EXPR:
+ /* This is unsafe for certain floats even in non-IEEE
+ formats. In IEEE, it is unsafe because it does
+ wrong for NaNs. */
+ if (FLOAT_TYPE_P (result_type)
+ && HONOR_NANS (result_type))
+ break;
+ /* FALLTHRU */
+ case BIT_XOR_EXPR:
case TRUNC_MOD_EXPR:
case CEIL_MOD_EXPR:
case FLOOR_MOD_EXPR:
@@ -195,6 +202,9 @@ avail_exprs_stack::simplify_binary_operation (gimple *stmt,
case FLOOR_DIV_EXPR:
case ROUND_DIV_EXPR:
case EXACT_DIV_EXPR:
+ /* Avoid _Fract types where we can't build 1. */
+ if (ALL_FRACT_MODE_P (TYPE_MODE (result_type)))
+ break;
return build_one_cst (result_type);
default:
@@ -204,8 +214,8 @@ avail_exprs_stack::simplify_binary_operation (gimple *stmt,
break;
}
- default:
- break;
+ default:
+ break;
}
}
}