diff options
author | Richard Biener <rguenther@suse.de> | 2019-02-01 13:41:43 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2019-02-01 13:41:43 +0000 |
commit | 577d65881ef0f90c790093a7e05cc28a14a45a26 (patch) | |
tree | 35bb180499ae6295918735a81458aa2d587cf826 /gcc/tree-chrec.c | |
parent | 61a8637c8893a25282e844ec217c31df8ad3b6e9 (diff) |
re PR tree-optimization/88597 (Compile time hog w/ -O1 -fpeel-loops)
2019-02-01 Richard Biener <rguenther@suse.de>
PR middle-end/88597
* tree-scalar-evolution.c (analyze_scalar_evolution): Set up
the instantiate cache.
(instantiate_scev_binary): Elide second operand procesing
if equal to the first.
* tree-chrec.c (chrec_contains_symbols): Add visited set.
(chrec_contains_undetermined): Likewise.
(tree_contains_chrecs): Likewise.
* gcc.dg/torture/pr88597.c: New testcase.
From-SVN: r268449
Diffstat (limited to 'gcc/tree-chrec.c')
-rw-r--r-- | gcc/tree-chrec.c | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c index a200d973dad..3987041ac19 100644 --- a/gcc/tree-chrec.c +++ b/gcc/tree-chrec.c @@ -934,8 +934,8 @@ is_multivariate_chrec (const_tree chrec) /* Determines whether the chrec contains symbolic names or not. */ -bool -chrec_contains_symbols (const_tree chrec) +static bool +chrec_contains_symbols (const_tree chrec, hash_set<const_tree> &visited) { int i, n; @@ -954,15 +954,22 @@ chrec_contains_symbols (const_tree chrec) n = TREE_OPERAND_LENGTH (chrec); for (i = 0; i < n; i++) - if (chrec_contains_symbols (TREE_OPERAND (chrec, i))) + if (chrec_contains_symbols (TREE_OPERAND (chrec, i), visited)) return true; return false; } +bool +chrec_contains_symbols (const_tree chrec) +{ + hash_set<const_tree> visited; + return chrec_contains_symbols (chrec, visited); +} + /* Determines whether the chrec contains undetermined coefficients. */ -bool -chrec_contains_undetermined (const_tree chrec) +static bool +chrec_contains_undetermined (const_tree chrec, hash_set<const_tree> &visited) { int i, n; @@ -972,19 +979,29 @@ chrec_contains_undetermined (const_tree chrec) if (chrec == NULL_TREE) return false; + if (visited.add (chrec)) + return false; + n = TREE_OPERAND_LENGTH (chrec); for (i = 0; i < n; i++) - if (chrec_contains_undetermined (TREE_OPERAND (chrec, i))) + if (chrec_contains_undetermined (TREE_OPERAND (chrec, i), visited)) return true; return false; } +bool +chrec_contains_undetermined (const_tree chrec) +{ + hash_set<const_tree> visited; + return chrec_contains_undetermined (chrec, visited); +} + /* Determines whether the tree EXPR contains chrecs, and increment SIZE if it is not a NULL pointer by an estimation of the depth of the tree. */ -bool -tree_contains_chrecs (const_tree expr, int *size) +static bool +tree_contains_chrecs (const_tree expr, int *size, hash_set<const_tree> &visited) { int i, n; @@ -999,11 +1016,19 @@ tree_contains_chrecs (const_tree expr, int *size) n = TREE_OPERAND_LENGTH (expr); for (i = 0; i < n; i++) - if (tree_contains_chrecs (TREE_OPERAND (expr, i), size)) + if (tree_contains_chrecs (TREE_OPERAND (expr, i), size, visited)) return true; return false; } +bool +tree_contains_chrecs (const_tree expr, int *size) +{ + hash_set<const_tree> visited; + return tree_contains_chrecs (expr, size, visited); +} + + /* Recursive helper function. */ static bool |