aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-math-opts.c
diff options
context:
space:
mode:
authorJoern Rennecke <joern.rennecke@embecosm.com>2013-04-10 09:54:25 +0000
committerJoern Rennecke <amylaar@gcc.gnu.org>2013-04-10 10:54:25 +0100
commitee8a9b7b507013b0431cabd314a245461c3b86b9 (patch)
tree1fe05c42b5420c41fb7bc6483e954ffd10927339 /gcc/tree-ssa-math-opts.c
parent6957a6f6f90ef5be56e154ee7ce8656ec0248e6f (diff)
downloadgcc-ee8a9b7b507013b0431cabd314a245461c3b86b9.zip
gcc-ee8a9b7b507013b0431cabd314a245461c3b86b9.tar.gz
gcc-ee8a9b7b507013b0431cabd314a245461c3b86b9.tar.bz2
re PR tree-optimization/55524 (If fnma exists but not fms, convert_mult_to_fma should prefer to former over the latter.)
gcc: 2013-04-10 Joern Rennecke <joern.rennecke@embecosm.com> PR tree-optimization/55524 * tree-ssa-math-opts.c (convert_mult_to_fma): Don't use an fms construct when we don't have an fms operation, but fnma, and it looks likely that we'll be able to use the latter. gcc/testsuite: 2013-04-10 Joern Rennecke <joern.rennecke@embecosm.com> PR tree-optimization/55524 * gcc.target/epiphany/fnma-1.c: New test. From-SVN: r197668
Diffstat (limited to 'gcc/tree-ssa-math-opts.c')
-rw-r--r--gcc/tree-ssa-math-opts.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index 2140ced..e7e09f6 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -2570,6 +2570,24 @@ convert_mult_to_fma (gimple mul_stmt, tree op1, tree op2)
return false;
}
+ /* If the subtrahend (gimple_assign_rhs2 (use_stmt)) is computed
+ by a MULT_EXPR that we'll visit later, we might be able to
+ get a more profitable match with fnma.
+ OTOH, if we don't, a negate / fma pair has likely lower latency
+ that a mult / subtract pair. */
+ if (use_code == MINUS_EXPR && !negate_p
+ && gimple_assign_rhs1 (use_stmt) == result
+ && optab_handler (fms_optab, TYPE_MODE (type)) == CODE_FOR_nothing
+ && optab_handler (fnma_optab, TYPE_MODE (type)) != CODE_FOR_nothing)
+ {
+ tree rhs2 = gimple_assign_rhs2 (use_stmt);
+ gimple stmt2 = SSA_NAME_DEF_STMT (rhs2);
+
+ if (has_single_use (rhs2)
+ && gimple_assign_rhs_code (stmt2) == MULT_EXPR)
+ return false;
+ }
+
/* We can't handle a * b + a * b. */
if (gimple_assign_rhs1 (use_stmt) == gimple_assign_rhs2 (use_stmt))
return false;