aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-loop-distribution.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2021-05-10 11:37:27 +0200
committerRichard Biener <rguenther@suse.de>2021-05-10 13:05:58 +0200
commit60af2db18013a0339302928ba98fee893ccc1957 (patch)
tree88a9e0c0e46e838e441917a516385ce5a032ff33 /gcc/tree-loop-distribution.c
parentcc1d563887b1fe3183a21572b2ea63466b2bfa3a (diff)
downloadgcc-60af2db18013a0339302928ba98fee893ccc1957.zip
gcc-60af2db18013a0339302928ba98fee893ccc1957.tar.gz
gcc-60af2db18013a0339302928ba98fee893ccc1957.tar.bz2
tree-optimization/100492 - avoid irreducible regions in loop distribution
When we distribute away a condition we rely on the ability to change it to either 1 != 0 or 0 != 0 depending on the direction of the exit branch in the respective loop. But when the loop contains an irreducible sub-region then for the conditions inside this this fails and can lead to infinite loops being generated. Avoid distibuting loops with irreducible sub-regions. 2021-05-10 Richard Biener <rguenther@suse.de> PR tree-optimization/100492 * tree-loop-distribution.c (find_seed_stmts_for_distribution): Find nothing when the loop contains an irreducible region. * gcc.dg/torture/pr100492.c: New testcase.
Diffstat (limited to 'gcc/tree-loop-distribution.c')
-rw-r--r--gcc/tree-loop-distribution.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 8b91a30..65aa1df 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -3203,6 +3203,16 @@ find_seed_stmts_for_distribution (class loop *loop, vec<gimple *> *work_list)
/* Initialize the worklist with stmts we seed the partitions with. */
for (unsigned i = 0; i < loop->num_nodes; ++i)
{
+ /* In irreducible sub-regions we don't know how to redirect
+ conditions, so fail. See PR100492. */
+ if (bbs[i]->flags & BB_IRREDUCIBLE_LOOP)
+ {
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, "loop %d contains an irreducible region.\n",
+ loop->num);
+ work_list->truncate (0);
+ break;
+ }
for (gphi_iterator gsi = gsi_start_phis (bbs[i]);
!gsi_end_p (gsi); gsi_next (&gsi))
{