This is an alternative to https://gcc.gnu.org/ml/gcc-patches/2018-11/msg00694.html
As richi suggested, this disables unrolling of loops vectorised with variable-length SVE
in the vectoriser itself through the loop->unroll member.
It took me a few tries to get it right, as it needs to be set to '1' to disable unrolling,
the rationale for that mechanism is described in the comment in cfgloop.h.
* tree-vect-loop.c (vect_transform_loop): Disable further unrolling
of the loop if vf is non-constant.
* gcc.target/aarch64/sve/unroll-1.c: New test.
From-SVN: r266281
+2018-11-19 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
+
+ * tree-vect-loop.c (vect_transform_loop): Disable further unrolling
+ of the loop if vf is non-constant.
+
2018-11-19 David Malcolm <dmalcolm@redhat.com>
PR tree-optimization/87025
+2018-11-19 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
+
+ * gcc.target/aarch64/sve/unroll-1.c: New test.
+
2018-11-19 David Malcolm <dmalcolm@redhat.com>
PR tree-optimization/87025
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+/* Check that simple loop is not fully unrolled. */
+
+void
+fully_peel_me (double *x)
+{
+ for (int i = 0; i < 5; i++)
+ x[i] = x[i] * 2;
+}
+
+/* { dg-final { scan-assembler-times {b..\t\.L.\n} 1 } } */
}
}
+ /* Loops vectorized with a variable factor won't benefit from
+ unrolling/peeling. */
+ if (!vf.is_constant ())
+ {
+ loop->unroll = 1;
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_NOTE, vect_location, "Disabling unrolling due to"
+ " variable-length vectorization factor\n");
+ }
/* Free SLP instances here because otherwise stmt reference counting
won't work. */
slp_instance instance;