aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-math-opts.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2020-03-26 08:33:57 +0100
committerRichard Biener <rguenther@suse.de>2020-03-26 08:36:42 +0100
commitd21dff5b4fee51ae432143065bededfc763dc344 (patch)
tree4ac6f918374acf8f3992052f73439fabfb5d8254 /gcc/tree-ssa-math-opts.c
parent27f8c8c4c9232c16e24030ae056822152fda409d (diff)
downloadgcc-d21dff5b4fee51ae432143065bededfc763dc344.zip
gcc-d21dff5b4fee51ae432143065bededfc763dc344.tar.gz
gcc-d21dff5b4fee51ae432143065bededfc763dc344.tar.bz2
widening_mul: restrict ops to be defined in the same basic-block when convert plusminus to widen
In the testcase for PR94269, widening_mul moves two multiply instructions from outside the loop to inside the loop, merging with two add instructions separately. This increases the cost of the loop. Like FMA detection in the same pass, simply restrict ops to be defined in the same basic-block to avoid possibly moving multiply to a different block with a higher execution frequency. 2020-03-26 Felix Yang <felix.yang@huawei.com> PR tree-optimization/94269 * tree-ssa-math-opts.c (convert_plusminus_to_widen): Restrict this operation to single basic block. * gcc.dg/pr94269.c: New test.
Diffstat (limited to 'gcc/tree-ssa-math-opts.c')
-rw-r--r--gcc/tree-ssa-math-opts.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index 54ba035..969c1a6 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -2715,11 +2715,14 @@ convert_plusminus_to_widen (gimple_stmt_iterator *gsi, gimple *stmt,
multiply-and-accumulate instructions.
If the widened-multiplication result has more than one uses, it is
- probably wiser not to do the conversion. */
+ probably wiser not to do the conversion. Also restrict this operation
+ to single basic block to avoid moving the multiply to a different block
+ with a higher execution frequency. */
if (code == PLUS_EXPR
&& (rhs1_code == MULT_EXPR || rhs1_code == WIDEN_MULT_EXPR))
{
if (!has_single_use (rhs1)
+ || gimple_bb (rhs1_stmt) != gimple_bb (stmt)
|| !is_widening_mult_p (rhs1_stmt, &type1, &mult_rhs1,
&type2, &mult_rhs2))
return false;
@@ -2729,6 +2732,7 @@ convert_plusminus_to_widen (gimple_stmt_iterator *gsi, gimple *stmt,
else if (rhs2_code == MULT_EXPR || rhs2_code == WIDEN_MULT_EXPR)
{
if (!has_single_use (rhs2)
+ || gimple_bb (rhs2_stmt) != gimple_bb (stmt)
|| !is_widening_mult_p (rhs2_stmt, &type1, &mult_rhs1,
&type2, &mult_rhs2))
return false;