]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR tree-optimization/83523
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Dec 2017 19:27:21 +0000 (19:27 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Dec 2017 19:27:21 +0000 (19:27 +0000)
* tree-ssa-math-opts.c (is_widening_mult_p): Return false if
for INTEGER_TYPE TYPE_OVERFLOW_TRAPS.
(convert_mult_to_fma): Likewise.

* g++.dg/tree-ssa/pr83523.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@255953 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tree-ssa/pr83523.C [new file with mode: 0644]
gcc/tree-ssa-math-opts.c

index 2b1aa73775ac7b22e5f012fbc2b314fcabc02d76..4b886cc2f4956a30b0945dfa05a0b7b1711f6a63 100644 (file)
@@ -1,5 +1,10 @@
 2017-12-21  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/83523
+       * tree-ssa-math-opts.c (is_widening_mult_p): Return false if
+       for INTEGER_TYPE TYPE_OVERFLOW_TRAPS.
+       (convert_mult_to_fma): Likewise.
+
        PR tree-optimization/83521
        * tree-ssa-phiopt.c (factor_out_conditional_conversion): Use
        gimple_build_assign without code on result of
index 566efde7a336526d8b6087a64e167b38a6774be8..088e8b0784f6710eecbf98938dabd92d1c4c486b 100644 (file)
@@ -1,5 +1,8 @@
 2017-12-21  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/83523
+       * g++.dg/tree-ssa/pr83523.C: New test.
+
        PR tree-optimization/83521
        * gcc.dg/pr83521.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr83523.C b/gcc/testsuite/g++.dg/tree-ssa/pr83523.C
new file mode 100644 (file)
index 0000000..d9adf90
--- /dev/null
@@ -0,0 +1,25 @@
+// PR tree-optimization/83523
+// { dg-do compile }
+// { dg-options "-O2 -fexceptions -fnon-call-exceptions -ftrapv" }
+
+#ifdef __SIZEOF_INT128__
+typedef __int128 T;
+typedef long long int U;
+#else
+typedef long long int T;
+typedef int U;
+#endif
+
+struct S { S (); ~S (); };
+void bar ();
+
+T
+foo (U x, U y)
+{
+  T z = x;
+  S s;
+  bar ();
+  z *= y;
+  bar ();
+  return z;
+}
index 4e8f5e728d0c8ef5ac564d8c3c999d8a6ff15e7e..553a37ccc3a18475fe673b6362e0b581a4546fda 100644 (file)
@@ -2196,8 +2196,12 @@ is_widening_mult_p (gimple *stmt,
 {
   tree type = TREE_TYPE (gimple_assign_lhs (stmt));
 
-  if (TREE_CODE (type) != INTEGER_TYPE
-      && TREE_CODE (type) != FIXED_POINT_TYPE)
+  if (TREE_CODE (type) == INTEGER_TYPE)
+    {
+      if (TYPE_OVERFLOW_TRAPS (type))
+       return false;
+    }
+  else if (TREE_CODE (type) != FIXED_POINT_TYPE)
     return false;
 
   if (!is_widening_mult_rhs_p (type, gimple_assign_rhs1 (stmt), type1_out,
@@ -2656,7 +2660,7 @@ convert_mult_to_fma (gimple *mul_stmt, tree op1, tree op2)
 
   /* We don't want to do bitfield reduction ops.  */
   if (INTEGRAL_TYPE_P (type)
-      && !type_has_mode_precision_p (type))
+      && (!type_has_mode_precision_p (type) || TYPE_OVERFLOW_TRAPS (type)))
     return false;
 
   /* If the target doesn't support it, don't generate it.  We assume that