aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTamar Christina <tamar.christina@arm.com>2024-09-23 11:45:43 +0100
committerTamar Christina <tamar.christina@arm.com>2024-09-23 11:45:43 +0100
commit09892448ebd8c396a26b2c09ba71f1e5a8dc42d7 (patch)
tree8ddac040f5300da88bcb5449670eedbb5f53df40 /gcc
parent723f7b6db841c1a101a2f5b3b6273d8449dae39e (diff)
downloadgcc-09892448ebd8c396a26b2c09ba71f1e5a8dc42d7.zip
gcc-09892448ebd8c396a26b2c09ba71f1e5a8dc42d7.tar.gz
gcc-09892448ebd8c396a26b2c09ba71f1e5a8dc42d7.tar.bz2
middle-end: Insert invariant instructions before the gsi [PR116812]
The new invariant statements should be inserted before the current statement and not after. This goes fine 99% of the time but when the current statement is a gcond the control flow gets corrupted. gcc/ChangeLog: PR tree-optimization/116812 * tree-vect-slp.cc (vect_slp_region): Fix insertion. gcc/testsuite/ChangeLog: PR tree-optimization/116812 * gcc.dg/vect/pr116812.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr116812.c17
-rw-r--r--gcc/tree-vect-slp.cc6
2 files changed, 19 insertions, 4 deletions
diff --git a/gcc/testsuite/gcc.dg/vect/pr116812.c b/gcc/testsuite/gcc.dg/vect/pr116812.c
new file mode 100644
index 0000000..3e83c13
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr116812.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O2 -fno-tree-dce -fno-tree-dse" } */
+
+int a, b, c, d, e, f[2], g, h;
+int k(int j) { return 2 >> a ? 2 >> a : a; }
+int main() {
+ int i;
+ for (; g; g = k(d = 0))
+ ;
+ if (a)
+ b && h;
+ for (e = 0; e < 2; e++)
+ c = d & 1 ? d : 0;
+ for (i = 0; i < 2; i++)
+ f[i] = 0;
+ return 0;
+}
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 600987d..7161492 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -9168,10 +9168,8 @@ vect_slp_region (vec<basic_block> bbs, vec<data_reference_p> datarefs,
dump_printf_loc (MSG_NOTE, vect_location,
"------>generating invariant statements\n");
- gimple_stmt_iterator gsi;
- gsi = gsi_after_labels (bb_vinfo->bbs[0]);
- gsi_insert_seq_after (&gsi, bb_vinfo->inv_pattern_def_seq,
- GSI_CONTINUE_LINKING);
+ bb_vinfo->insert_seq_on_entry (NULL,
+ bb_vinfo->inv_pattern_def_seq);
}
}
else