aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2023-04-21 15:53:21 +0200
committerJan Hubicka <jh@suse.cz>2023-04-21 15:54:06 +0200
commit2f4e45101dd812a6fcc1e5d96efedc60b8735432 (patch)
tree942c1c48a5ca34e18381cd4263cfe5c8fac5555a /gcc
parent2e047c00e983b6d9037906feac3a215ef829c82f (diff)
downloadgcc-2f4e45101dd812a6fcc1e5d96efedc60b8735432.zip
gcc-2f4e45101dd812a6fcc1e5d96efedc60b8735432.tar.gz
gcc-2f4e45101dd812a6fcc1e5d96efedc60b8735432.tar.bz2
Fix latent bug in loop header copying which forgets to update the loop header pointer
gcc/ChangeLog: 2023-04-21 Jan Hubicka <hubicka@ucw.cz> Ondrej Kubanek <kubanek0ondrej@gmail.com> * tree-ssa-loop-ch.cc (ch_base::copy_headers): Update loop header and latch.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/tree-ssa-loop-ch.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/tree-ssa-loop-ch.cc b/gcc/tree-ssa-loop-ch.cc
index ddf025c..560df39 100644
--- a/gcc/tree-ssa-loop-ch.cc
+++ b/gcc/tree-ssa-loop-ch.cc
@@ -542,6 +542,17 @@ ch_base::copy_headers (function *fun)
}
}
+ /* Update header of the loop. */
+ loop->header = header;
+ /* Find correct latch. We only duplicate chain of conditionals so
+ there should be precisely two edges to the new header. One entry
+ edge and one to latch. */
+ FOR_EACH_EDGE (e, ei, loop->header->preds)
+ if (header != e->src)
+ {
+ loop->latch = e->src;
+ break;
+ }
/* Ensure that the latch and the preheader is simple (we know that they
are not now, since there was the loop exit condition. */
split_edge (loop_preheader_edge (loop));
@@ -561,6 +572,8 @@ ch_base::copy_headers (function *fun)
if (changed)
{
+ if (flag_checking)
+ verify_loop_structure ();
update_ssa (TODO_update_ssa);
/* After updating SSA form perform CSE on the loop header
copies. This is esp. required for the pass before