--- /dev/null
+/* { dg-do compile } */
+/* { dg-add-options vect_early_break } */
+/* { dg-require-effective-target vect_early_break } */
+/* { dg-require-effective-target vect_int } */
+
+/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */
+
+#ifndef N
+#define N 800
+#endif
+unsigned vect_a[N];
+unsigned vect_b[N];
+
+unsigned test4(unsigned x)
+{
+ unsigned ret = 0;
+ for (int i = 0; i < N; i++)
+ {
+ vect_b[i] = x + i;
+ if (vect_a[i] != x)
+ break;
+foo:
+ vect_a[i] = x;
+ }
+ return ret;
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-add-options vect_early_break } */
+/* { dg-require-effective-target vect_early_break } */
+/* { dg-require-effective-target vect_int } */
+
+/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */
+
+#ifndef N
+#define N 800
+#endif
+unsigned vect_a[N];
+unsigned vect_b[N];
+
+unsigned test4(unsigned x)
+{
+ unsigned ret = 0;
+ for (int i = 0; i < N; i++)
+ {
+ vect_b[i] = x + i;
+ if (vect_a[i] != x)
+ break;
+ vect_a[i] = x;
+foo:
+ }
+ return ret;
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-add-options vect_early_break } */
+/* { dg-require-effective-target vect_early_break } */
+/* { dg-require-effective-target vect_int } */
+
+/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */
+
+#ifndef N
+#define N 800
+#endif
+unsigned vect_a[N];
+unsigned vect_b[N];
+
+unsigned test4(unsigned x)
+{
+ unsigned ret = 0;
+ for (int i = 0; i < N; i++)
+ {
+ vect_b[i] = x + i;
+foo:
+ if (vect_a[i] != x)
+ break;
+ vect_a[i] = x;
+ }
+ return ret;
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-add-options vect_early_break } */
+/* { dg-require-effective-target vect_early_break } */
+/* { dg-require-effective-target vect_int } */
+
+/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */
+
+#ifndef N
+#define N 800
+#endif
+unsigned vect_a[N];
+unsigned vect_b[N];
+
+unsigned test4(unsigned x)
+{
+ unsigned ret = 0;
+ for (int i = 0; i < N; i++)
+ {
+foo:
+ vect_b[i] = x + i;
+ if (vect_a[i] != x)
+ break;
+ vect_a[i] = x;
+ }
+ return ret;
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-add-options vect_early_break } */
+/* { dg-require-effective-target vect_early_break } */
+/* { dg-require-effective-target vect_int } */
+
+/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */
+
+#ifndef N
+#define N 800
+#endif
+unsigned vect_a[N];
+unsigned vect_b[N];
+
+unsigned test4(unsigned x)
+{
+ unsigned ret = 0;
+ for (int i = 0; i < N; i++)
+ {
+ vect_b[i] = x + i;
+ if (vect_a[i] != x)
+foo:
+ break;
+ vect_a[i] = x;
+ }
+ return ret;
+}
trapped already during loop form analysis. */
gcc_assert (dest_bb->loop_father == loop);
+ /* Check that the destination block we picked has only one pred. To relax this we
+ have to take special care when moving the statements. We don't currently support
+ such control flow however this check is there to simplify how we handle
+ labels that may be present anywhere in the IL. This check is to ensure that the
+ labels aren't significant for the CFG. */
+ if (!single_pred (dest_bb))
+ return opt_result::failure_at (vect_location,
+ "chosen loop exit block (BB %d) does not have a "
+ "single predecessor which is currently not "
+ "supported for early break vectorization.\n",
+ dest_bb->index);
+
LOOP_VINFO_EARLY_BRK_DEST_BB (loop_vinfo) = dest_bb;
if (!LOOP_VINFO_EARLY_BRK_VUSES (loop_vinfo).is_empty ())
/* Move all stmts that need moving. */
basic_block dest_bb = LOOP_VINFO_EARLY_BRK_DEST_BB (loop_vinfo);
- gimple_stmt_iterator dest_gsi = gsi_start_bb (dest_bb);
+ gimple_stmt_iterator dest_gsi = gsi_after_labels (dest_bb);
for (gimple *stmt : LOOP_VINFO_EARLY_BRK_STORES (loop_vinfo))
{