aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-loop-manip.cc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2024-01-19 09:23:48 +0100
committerRichard Biener <rguenther@suse.de>2024-01-19 10:43:07 +0100
commit6ce7008cfa1a240895ecca0898e7dbaecd975567 (patch)
tree809e96885a51aaac33bf9d8ea29bb6c44c9fd6fe /gcc/tree-vect-loop-manip.cc
parent3670fb86bcd670f9183d7ff43612746d40dc113f (diff)
downloadgcc-6ce7008cfa1a240895ecca0898e7dbaecd975567.zip
gcc-6ce7008cfa1a240895ecca0898e7dbaecd975567.tar.gz
gcc-6ce7008cfa1a240895ecca0898e7dbaecd975567.tar.bz2
tree-optimization/113494 - Fix two observed regressions with r14-8206
The following handles the situation where we lack a loop-closed PHI for a virtual operand because a loop exit goes to a code region not having any virtual use (an endless loop). It also handles the situation of edge redirection re-allocating a PHI node in the destination block so we have to re-lookup that before populating the new PHI argument. PR tree-optimization/113494 * tree-vect-loop-manip.cc (slpeel_tree_duplicate_loop_to_edge_cfg): Handle endless loop on exit. Handle re-allocated PHI.
Diffstat (limited to 'gcc/tree-vect-loop-manip.cc')
-rw-r--r--gcc/tree-vect-loop-manip.cc26
1 files changed, 21 insertions, 5 deletions
diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc
index 983ed2e..1477906 100644
--- a/gcc/tree-vect-loop-manip.cc
+++ b/gcc/tree-vect-loop-manip.cc
@@ -1629,11 +1629,17 @@ slpeel_tree_duplicate_loop_to_edge_cfg (class loop *loop, edge loop_exit,
alt_loop_exit_block = split_edge (exit);
if (!need_virtual_phi)
continue;
- if (vphi_def && !vphi)
- vphi = create_phi_node (copy_ssa_name (vphi_def),
- alt_loop_exit_block);
if (vphi_def)
- add_phi_arg (vphi, vphi_def, exit, UNKNOWN_LOCATION);
+ {
+ if (!vphi)
+ vphi = create_phi_node (copy_ssa_name (vphi_def),
+ alt_loop_exit_block);
+ else
+ /* Edge redirection might re-allocate the PHI node
+ so we have to rediscover it. */
+ vphi = get_virtual_phi (alt_loop_exit_block);
+ add_phi_arg (vphi, vphi_def, exit, UNKNOWN_LOCATION);
+ }
}
set_immediate_dominator (CDI_DOMINATORS, new_preheader,
@@ -1748,7 +1754,17 @@ slpeel_tree_duplicate_loop_to_edge_cfg (class loop *loop, edge loop_exit,
if (virtual_operand_p (alt_arg))
{
gphi *vphi = get_virtual_phi (alt_loop_exit_block);
- alt_arg = gimple_phi_result (vphi);
+ /* ??? When the exit yields to a path without
+ any virtual use we can miss a LC PHI for the
+ live virtual operand. Simply choosing the
+ one live at the start of the loop header isn't
+ correct, but we should get here only with
+ early-exit vectorization which will move all
+ defs after the main exit, so leave a temporarily
+ wrong virtual operand in place. This happens
+ for gcc.c-torture/execute/20150611-1.c */
+ if (vphi)
+ alt_arg = gimple_phi_result (vphi);
}
edge main_e = single_succ_edge (alt_loop_exit_block);
SET_PHI_ARG_DEF_ON_EDGE (to_phi, main_e, alt_arg);