diff options
author | Richard Guenther <rguenther@suse.de> | 2011-03-11 16:36:16 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2011-03-11 16:36:16 +0000 |
commit | a758fd670cbf0935c6fa6cac3336b184f5c3c92a (patch) | |
tree | 50e8dad10f8d14f7dbb32ac528ad778bf92feeed | |
parent | 03dfda54535c36cef955c0d06d46b82e2356574c (diff) | |
download | gcc-a758fd670cbf0935c6fa6cac3336b184f5c3c92a.zip gcc-a758fd670cbf0935c6fa6cac3336b184f5c3c92a.tar.gz gcc-a758fd670cbf0935c6fa6cac3336b184f5c3c92a.tar.bz2 |
re PR tree-optimization/48067 (FMA with no add operand produced by convert_mul_to_fma)
2011-03-11 Richard Guenther <rguenther@suse.de>
PR tree-optimization/48067
* tree-ssa-math-opts.c (convert_mult_to_fma): Verify the
multiplication result will be only used once on the target
stmt.
* gcc.dg/pr48067.c: New testcase.
From-SVN: r170877
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr48067.c | 11 | ||||
-rw-r--r-- | gcc/tree-ssa-math-opts.c | 8 |
4 files changed, 31 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8a5ca08..78a6a32 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ 2011-03-11 Richard Guenther <rguenther@suse.de> + PR tree-optimization/48067 + * tree-ssa-math-opts.c (convert_mult_to_fma): Verify the + multiplication result will be only used once on the target + stmt. + +2011-03-11 Richard Guenther <rguenther@suse.de> + * doc/invoke.texi (max-inline-insns-single): Adjust default value. 2011-03-11 Richard Guenther <rguenther@suse.de> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 69b6ad5..5976bb4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2011-03-11 Richard Guenther <rguenther@suse.de> + PR tree-optimization/48067 + * gcc.dg/pr48067.c: New testcase. + +2011-03-11 Richard Guenther <rguenther@suse.de> + PR lto/48073 * g++.dg/lto/20110311-1_0.C: New testcase. diff --git a/gcc/testsuite/gcc.dg/pr48067.c b/gcc/testsuite/gcc.dg/pr48067.c new file mode 100644 index 0000000..7796909 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr48067.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math -fno-tree-forwprop -fno-tree-reassoc" } */ +/* { dg-options "-O2 -ffast-math -fno-tree-forwprop -fno-tree-reassoc -mfma4" { target x86_64-*-* i?86-*-* } } */ + +float +foo (float x, float cim) +{ + float c = x * cim; + float d = -c; + return c - d; +} diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index ed9b7a9..6e2213c 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -1557,6 +1557,9 @@ convert_mult_to_fma (gimple mul_stmt, tree op1, tree op2) /* A negate on the multiplication leads to FNMA. */ if (use_code == NEGATE_EXPR) { + ssa_op_iter iter; + tree use; + result = gimple_assign_lhs (use_stmt); /* Make sure the negate statement becomes dead with this @@ -1565,6 +1568,11 @@ convert_mult_to_fma (gimple mul_stmt, tree op1, tree op2) &use_p, &neguse_stmt)) return false; + /* Make sure the multiplication isn't also used on that stmt. */ + FOR_EACH_SSA_TREE_OPERAND (use, neguse_stmt, iter, SSA_OP_USE) + if (use == mul_result) + return false; + /* Re-validate. */ use_stmt = neguse_stmt; if (gimple_bb (use_stmt) != gimple_bb (mul_stmt)) |