aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-ivcanon.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2018-07-11 07:04:59 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2018-07-11 07:04:59 +0000
commit286fa9840d9358f8d001b7b47b29f6499e9446f5 (patch)
treeb05af948e966f2731876b6f1f5da159442a273bc /gcc/tree-ssa-loop-ivcanon.c
parent7b8bddb4d367a982edae67e14209fabc0e3e0655 (diff)
downloadgcc-286fa9840d9358f8d001b7b47b29f6499e9446f5.zip
gcc-286fa9840d9358f8d001b7b47b29f6499e9446f5.tar.gz
gcc-286fa9840d9358f8d001b7b47b29f6499e9446f5.tar.bz2
tree-ssa-loop-ivcanon.c (tree_unroll_loops_completely_1): Rework father_bb setting in a way to avoid propagating constants multiple times...
2018-07-10 Richard Biener <rguenther@suse.de> * tree-ssa-loop-ivcanon.c (tree_unroll_loops_completely_1): Rework father_bb setting in a way to avoid propagating constants multiple times on a loop body. From-SVN: r262550
Diffstat (limited to 'gcc/tree-ssa-loop-ivcanon.c')
-rw-r--r--gcc/tree-ssa-loop-ivcanon.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c
index 5f741c3..326589f 100644
--- a/gcc/tree-ssa-loop-ivcanon.c
+++ b/gcc/tree-ssa-loop-ivcanon.c
@@ -1378,17 +1378,37 @@ tree_unroll_loops_completely_1 (bool may_increase_size, bool unroll_outer,
/* Process inner loops first. Don't walk loops added by the recursive
calls because SSA form is not up-to-date. They can be handled in the
next iteration. */
+ bitmap child_father_bbs = NULL;
for (inner = loop->inner; inner != NULL; inner = inner->next)
if ((unsigned) inner->num < num)
- changed |= tree_unroll_loops_completely_1 (may_increase_size,
- unroll_outer, father_bbs,
- inner);
+ {
+ if (!child_father_bbs)
+ child_father_bbs = BITMAP_ALLOC (NULL);
+ if (tree_unroll_loops_completely_1 (may_increase_size, unroll_outer,
+ child_father_bbs, inner))
+ {
+ bitmap_ior_into (father_bbs, child_father_bbs);
+ bitmap_clear (child_father_bbs);
+ changed = true;
+ }
+ }
+ if (child_father_bbs)
+ BITMAP_FREE (child_father_bbs);
/* If we changed an inner loop we cannot process outer loops in this
iteration because SSA form is not up-to-date. Continue with
siblings of outer loops instead. */
if (changed)
- return true;
+ {
+ /* If we are recorded as father clear all other fathers that
+ are necessarily covered already to avoid redundant work. */
+ if (bitmap_bit_p (father_bbs, loop->header->index))
+ {
+ bitmap_clear (father_bbs);
+ bitmap_set_bit (father_bbs, loop->header->index);
+ }
+ return true;
+ }
/* Don't unroll #pragma omp simd loops until the vectorizer
attempts to vectorize those. */
@@ -1418,7 +1438,13 @@ tree_unroll_loops_completely_1 (bool may_increase_size, bool unroll_outer,
computations; otherwise, the size might blow up before the
iteration is complete and the IR eventually cleaned up. */
if (loop_outer (loop_father))
- bitmap_set_bit (father_bbs, loop_father->header->index);
+ {
+ /* Once we process our father we will have processed
+ the fathers of our children as well, so avoid doing
+ redundant work and clear fathers we've gathered sofar. */
+ bitmap_clear (father_bbs);
+ bitmap_set_bit (father_bbs, loop_father->header->index);
+ }
return true;
}