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.
--- /dev/null
+/* { 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;
+}
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