summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2021-11-17 14:14:06 -0500
committerAndrew MacLeod <amacleod@redhat.com>2021-11-19 11:38:06 -0500
commitee448a523d377f9ed882dac806d2f5001bfa2432 (patch)
tree3056fe7c09a1e9b209a33b169a9c91a7b8a21468
parentf47870e6a272dfe740a38422030c6c68e0fc7ff8 (diff)
downloadgcc-ee448a523d377f9ed882dac806d2f5001bfa2432.tar.gz
Limit depth for all GORI expressions.
Apply the logical_depth limit ranger uses to all stmts with multiple ssa-names to avoid excessive outgoing calculations. gcc/ PR tree-optimization/103254 * gimple-range-gori.cc (range_def_chain::get_def_chain): Limit the depth for all statements with multple ssa names. gcc/testsuite/ * gcc.dg/pr103254.c: New.
-rw-r--r--gcc/gimple-range-gori.cc20
-rw-r--r--gcc/testsuite/gcc.dg/pr103254.c25
2 files changed, 34 insertions, 11 deletions
diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc
index fb2d571ef44..911d7ac4ec8 100644
--- a/gcc/gimple-range-gori.cc
+++ b/gcc/gimple-range-gori.cc
@@ -331,7 +331,6 @@ range_def_chain::get_def_chain (tree name)
{
tree ssa1, ssa2, ssa3;
unsigned v = SSA_NAME_VERSION (name);
- bool is_logical = false;
// If it has already been processed, just return the cached value.
if (has_def_chain (name))
@@ -348,15 +347,6 @@ range_def_chain::get_def_chain (tree name)
gimple *stmt = SSA_NAME_DEF_STMT (name);
if (gimple_range_handler (stmt))
{
- is_logical = is_gimple_logical_p (stmt);
- // Terminate the def chains if we see too many cascading logical stmts.
- if (is_logical)
- {
- if (m_logical_depth == param_ranger_logical_depth)
- return NULL;
- m_logical_depth++;
- }
-
ssa1 = gimple_range_ssa_p (gimple_range_operand1 (stmt));
ssa2 = gimple_range_ssa_p (gimple_range_operand2 (stmt));
ssa3 = NULL_TREE;
@@ -376,6 +366,14 @@ range_def_chain::get_def_chain (tree name)
return NULL;
}
+ // Terminate the def chains if we see too many cascading stmts.
+ if (m_logical_depth == param_ranger_logical_depth)
+ return NULL;
+
+ // Increase the depth if we have a pair of ssa-names.
+ if (ssa1 && ssa2)
+ m_logical_depth++;
+
register_dependency (name, ssa1, gimple_bb (stmt));
register_dependency (name, ssa2, gimple_bb (stmt));
register_dependency (name, ssa3, gimple_bb (stmt));
@@ -383,7 +381,7 @@ range_def_chain::get_def_chain (tree name)
if (!ssa1 && !ssa2 & !ssa3)
set_import (m_def_chain[v], name, NULL);
- if (is_logical)
+ if (ssa1 && ssa2)
m_logical_depth--;
return m_def_chain[v].bm;
diff --git a/gcc/testsuite/gcc.dg/pr103254.c b/gcc/testsuite/gcc.dg/pr103254.c
new file mode 100644
index 00000000000..62d2415f216
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr103254.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+/* { dg-timeout 10 } */
+
+short int i;
+
+void
+foo (void)
+{
+ for (i = 1; i < 2; i += 4)
+ {
+ int j;
+
+ for (j = 0; j < 5; j += 4)
+ {
+ int k;
+
+ for (k = 0; k < 68; k += 4)
+ {
+ i &= j;
+ j &= i;
+ }
+ }
+ }
+}