aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2023-02-07 13:01:12 +0100
committerRichard Biener <rguenther@suse.de>2023-02-07 14:39:31 +0100
commit295adfc9ed20468cdaba3afe258d57b58a8df792 (patch)
tree7f2c76fd7eefb95476d6ac1192cf1625f67acf35 /gcc
parent5321d53279a60ee589a3c9779beb46503f9fc49f (diff)
downloadgcc-295adfc9ed20468cdaba3afe258d57b58a8df792.zip
gcc-295adfc9ed20468cdaba3afe258d57b58a8df792.tar.gz
gcc-295adfc9ed20468cdaba3afe258d57b58a8df792.tar.bz2
tree-optimization/26854 - compile-time hog in SSA forwprop
The following addresses tree forward propagate : 12.41 ( 9%) seen with the compile.i testcase of this PR which points at the has_use_on_stmt function which, for SSA names with many uses is slow. The solution is to instead of immediate uses, look at stmt operands to identify whether a name has a use on a stmt. That improves SSA forwprop to tree forward propagate : 1.30 ( 0%) for this testcase. PR tree-optimization/26854 * gimple-fold.cc (has_use_on_stmt): Look at stmt operands instead of immediate uses.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gimple-fold.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 379d2e9..935e800 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -5767,15 +5767,17 @@ gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace)
}
-/* Return true whether NAME has a use on STMT. */
+/* Return true whether NAME has a use on STMT. Note this can return
+ false even though there's a use on STMT if SSA operands are not
+ up-to-date. */
static bool
has_use_on_stmt (tree name, gimple *stmt)
{
- imm_use_iterator iter;
- use_operand_p use_p;
- FOR_EACH_IMM_USE_FAST (use_p, iter, name)
- if (USE_STMT (use_p) == stmt)
+ ssa_op_iter iter;
+ tree op;
+ FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_USE)
+ if (op == name)
return true;
return false;
}