aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2024-10-13 15:12:44 +0200
committerRichard Biener <rguenth@gcc.gnu.org>2024-10-14 08:14:37 +0200
commit566740013b3445162b8c4bc2205e4e568d014968 (patch)
tree38fb5482cf9882ae6d559b2685b9de59f3146e61
parentb717c462b96e7870f8081d2bc330e4749a4b0538 (diff)
downloadgcc-566740013b3445162b8c4bc2205e4e568d014968.zip
gcc-566740013b3445162b8c4bc2205e4e568d014968.tar.gz
gcc-566740013b3445162b8c4bc2205e4e568d014968.tar.bz2
tree-optimization/116290 - fix compare-debug issue in ldist
Loop distribution does different analysis with -g0/-g due to counting a debug stmt starting a BB against a limit which will everntually lead to different IVOPTs choices. I've fixed a possible IVOPTs issue on the way even though it doesn't make a difference here. PR tree-optimization/116290 * tree-loop-distribution.cc (determine_reduction_stmt_1): PHIs have no debug variants. Start with first non-debug real stmt. * tree-ssa-loop-ivopts.cc (find_givs_in_bb): Do not analyze debug stmts. * gcc.dg/pr116290.c: New testcase.
-rw-r--r--gcc/testsuite/gcc.dg/pr116290.c18
-rw-r--r--gcc/tree-loop-distribution.cc6
-rw-r--r--gcc/tree-ssa-loop-ivopts.cc3
3 files changed, 23 insertions, 4 deletions
diff --git a/gcc/testsuite/gcc.dg/pr116290.c b/gcc/testsuite/gcc.dg/pr116290.c
new file mode 100644
index 0000000..97b946b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr116290.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-g -O2 -fcompare-debug" } */
+
+char *camel_message_info_class_intern_init_part;
+void g_once_init_enter();
+void camel_message_info_class_intern_init() {
+ int ii;
+ char *label;
+ for (; camel_message_info_class_intern_init_part[ii]; ii++)
+ if (camel_message_info_class_intern_init_part) {
+ if (label && *label)
+ g_once_init_enter();
+ label = &camel_message_info_class_intern_init_part[ii + 1];
+ camel_message_info_class_intern_init_part[ii] = ' ';
+ }
+ if (label)
+ g_once_init_enter();
+}
diff --git a/gcc/tree-loop-distribution.cc b/gcc/tree-loop-distribution.cc
index f0430ed..d7013ba 100644
--- a/gcc/tree-loop-distribution.cc
+++ b/gcc/tree-loop-distribution.cc
@@ -3552,7 +3552,7 @@ determine_reduction_stmt_1 (const loop_p loop, const basic_block *bbs)
basic_block bb = bbs[i];
for (gphi_iterator bsi = gsi_start_phis (bb); !gsi_end_p (bsi);
- gsi_next_nondebug (&bsi))
+ gsi_next (&bsi))
{
gphi *phi = bsi.phi ();
if (virtual_operand_p (gimple_phi_result (phi)))
@@ -3565,8 +3565,8 @@ determine_reduction_stmt_1 (const loop_p loop, const basic_block *bbs)
}
}
- for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi);
- gsi_next_nondebug (&bsi), ++ninsns)
+ for (gimple_stmt_iterator bsi = gsi_start_nondebug_bb (bb);
+ !gsi_end_p (bsi); gsi_next_nondebug (&bsi), ++ninsns)
{
/* Bail out early for loops which are unlikely to match. */
if (ninsns > 16)
diff --git a/gcc/tree-ssa-loop-ivopts.cc b/gcc/tree-ssa-loop-ivopts.cc
index dfe1b254..7441324 100644
--- a/gcc/tree-ssa-loop-ivopts.cc
+++ b/gcc/tree-ssa-loop-ivopts.cc
@@ -1461,7 +1461,8 @@ find_givs_in_bb (struct ivopts_data *data, basic_block bb)
gimple_stmt_iterator bsi;
for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
- find_givs_in_stmt (data, gsi_stmt (bsi));
+ if (!is_gimple_debug (gsi_stmt (bsi)))
+ find_givs_in_stmt (data, gsi_stmt (bsi));
}
/* Finds general ivs. */