public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8953] tree-optimization/113902 - fix VUSE update in move_early_exit_stmts
@ 2024-02-13 11:43 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2024-02-13 11:43 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:aab45e2bbec340201f8faaccfa24756bc09cb7db
commit r14-8953-gaab45e2bbec340201f8faaccfa24756bc09cb7db
Author: Richard Biener <rguenther@suse.de>
Date: Tue Feb 13 11:38:48 2024 +0100
tree-optimization/113902 - fix VUSE update in move_early_exit_stmts
The following adjusts move_early_exit_stmts to track the last seen
VUSE instead of getting it from the last store which could be a PHI
where gimple_vuse doesn't work.
PR tree-optimization/113902
* tree-vect-loop.cc (move_early_exit_stmts): Track
last_seen_vuse for VUSE updating.
* gcc.dg/vect/pr113902.c: New testcase.
Diff:
---
gcc/testsuite/gcc.dg/vect/pr113902.c | 15 +++++++++++++++
gcc/tree-vect-loop.cc | 12 +++++++-----
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/vect/pr113902.c b/gcc/testsuite/gcc.dg/vect/pr113902.c
new file mode 100644
index 000000000000..a2fe3df26e20
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr113902.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-add-options vect_early_break } */
+
+int g_66, g_80_2;
+void func_1func_41(int p_43)
+{
+lbl_1434:
+ g_80_2 = 0;
+ for (; g_80_2 <= 7; g_80_2 += 1) {
+ g_66 = 0;
+ for (; g_66 <= 7; g_66 += 1)
+ if (p_43)
+ goto lbl_1434;
+ }
+}
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 367077965fd9..9e26b09504df 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -11787,6 +11787,7 @@ move_early_exit_stmts (loop_vec_info loop_vinfo)
basic_block dest_bb = LOOP_VINFO_EARLY_BRK_DEST_BB (loop_vinfo);
gimple_stmt_iterator dest_gsi = gsi_after_labels (dest_bb);
+ tree last_seen_vuse = NULL_TREE;
for (gimple *stmt : LOOP_VINFO_EARLY_BRK_STORES (loop_vinfo))
{
/* We have to update crossed degenerate virtual PHIs. Simply
@@ -11805,6 +11806,7 @@ move_early_exit_stmts (loop_vec_info loop_vinfo)
}
auto gsi = gsi_for_stmt (stmt);
remove_phi_node (&gsi, true);
+ last_seen_vuse = vuse;
continue;
}
@@ -11819,17 +11821,17 @@ move_early_exit_stmts (loop_vec_info loop_vinfo)
gimple_stmt_iterator stmt_gsi = gsi_for_stmt (stmt);
gsi_move_before (&stmt_gsi, &dest_gsi, GSI_NEW_STMT);
+ last_seen_vuse = gimple_vuse (stmt);
}
/* Update all the stmts with their new reaching VUSES. */
- tree vuse
- = gimple_vuse (LOOP_VINFO_EARLY_BRK_STORES (loop_vinfo).last ());
for (auto p : LOOP_VINFO_EARLY_BRK_VUSES (loop_vinfo))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_NOTE, vect_location,
- "updating vuse to %T for load %G", vuse, p);
- gimple_set_vuse (p, vuse);
+ "updating vuse to %T for load %G",
+ last_seen_vuse, p);
+ gimple_set_vuse (p, last_seen_vuse);
update_stmt (p);
}
@@ -11837,7 +11839,7 @@ move_early_exit_stmts (loop_vec_info loop_vinfo)
for (edge e : get_loop_exit_edges (LOOP_VINFO_LOOP (loop_vinfo)))
if (!dominated_by_p (CDI_DOMINATORS, e->src, dest_bb))
if (gphi *phi = get_virtual_phi (e->dest))
- SET_PHI_ARG_DEF_ON_EDGE (phi, e, vuse);
+ SET_PHI_ARG_DEF_ON_EDGE (phi, e, last_seen_vuse);
}
/* Function vect_transform_loop.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-02-13 11:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-13 11:43 [gcc r14-8953] tree-optimization/113902 - fix VUSE update in move_early_exit_stmts Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).