re PR tree-optimization/51396 (ICE: verify_flow_info failed: BB 4 can not throw but...
authorJakub Jelinek <jakub@redhat.com>
Mon, 5 Dec 2011 20:56:14 +0000 (21:56 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 5 Dec 2011 20:56:14 +0000 (21:56 +0100)
PR tree-optimization/51396
* tree-ssa-math-opts.c (convert_mult_to_fma): Don't optimize
if MUL_RESULT has zero uses.

* g++.dg/opt/pr51396.C: New test.

From-SVN: r182028

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

index 52c1de56aefaecaa5faa61b6d8ca2f3c4b2acdc0..318b4ceadb113087ddc2726b2c52ceade717a661 100644 (file)
@@ -1,5 +1,9 @@
 2011-12-05  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/51396
+       * tree-ssa-math-opts.c (convert_mult_to_fma): Don't optimize
+       if MUL_RESULT has zero uses.
+
        PR debug/51410
        * c-decl.c (pop_scope): Don't add DECL_EXTERNAL decls
        for debug info if scope is file_scope.
index 654a56ea8068dac36832ca9ccbb79885acfe61f8..efb2ed42af3025311d68ab34e14303886da32cbd 100644 (file)
@@ -1,5 +1,8 @@
 2011-12-05  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/51396
+       * g++.dg/opt/pr51396.C: New test.
+
        PR debug/51410
        * gcc.dg/debug/dwarf2/pr51410.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/opt/pr51396.C b/gcc/testsuite/g++.dg/opt/pr51396.C
new file mode 100644 (file)
index 0000000..f2b21b6
--- /dev/null
@@ -0,0 +1,24 @@
+// PR tree-optimization/51396
+// { dg-do compile }
+// { dg-options "-O2 -fnon-call-exceptions -mfma" }
+// { dg-options "-O2 -fnon-call-exceptions -mfma" { target i?86-*-* x86_64-*-* } }
+
+double baz (double) throw ();
+
+struct C
+{
+  C (double d = 0.0) : c (d) {}
+  double c;
+};
+
+static inline void
+foo (double x, const C &y)
+{
+  x ? (y.c * baz (x)) : (C (), y);
+}
+
+void
+bar (double x, C y)
+{
+  foo (x, y);
+}
index 75abb3369a1e397d4baa28f33cc9fe549f7db5e9..06a4505079fb1b9ac363f7169b5cc491e1f61981 100644 (file)
@@ -2429,6 +2429,12 @@ convert_mult_to_fma (gimple mul_stmt, tree op1, tree op2)
   if (optab_handler (fma_optab, TYPE_MODE (type)) == CODE_FOR_nothing)
     return false;
 
+  /* If the multiplication has zero uses, it is kept around probably because
+     of -fnon-call-exceptions.  Don't optimize it away in that case,
+     it is DCE job.  */
+  if (has_zero_uses (mul_result))
+    return false;
+
   /* Make sure that the multiplication statement becomes dead after
      the transformation, thus that all uses are transformed to FMAs.
      This means we assume that an FMA operation has the same cost