summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2011-12-05 20:56:14 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2011-12-05 20:56:14 +0000
commit5ed3d3b86cc6b24082dfe76a20b3ce81db57f6f5 (patch)
treeee9328a0873b74fdcbd5ebe510e67699561cd4bf
parentadd5c2aefc1dfcfeb28b796697d519d38d9d472e (diff)
downloadppe42-gcc-5ed3d3b86cc6b24082dfe76a20b3ce81db57f6f5.tar.gz
ppe42-gcc-5ed3d3b86cc6b24082dfe76a20b3ce81db57f6f5.zip
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182028 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/opt/pr51396.C24
-rw-r--r--gcc/tree-ssa-math-opts.c6
4 files changed, 37 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 52c1de56aef..318b4ceadb1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 654a56ea806..efb2ed42af3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 00000000000..f2b21b60d53
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr51396.C
@@ -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);
+}
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index 75abb3369a1..06a4505079f 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -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
OpenPOWER on IntegriCloud