--- /dev/null
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_double } */
+
+double dotprod(const double *a, const double *b, unsigned long long n)
+{
+ double d1 = 0.0;
+ double d2 = 0.0;
+
+ for (unsigned long long i = 0; i < n; i += 2) {
+ d1 += a[i] * b[i];
+ d2 += a[i + 1] * b[i + 1];
+ }
+
+ return (d1 + d2);
+}
+
+/* We should use a SLP reduction even without -ffast-math by using a
+ VF of one. */
+/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */
+/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */
cases, so we need to check that this is ok. One exception is when
vectorizing an outer-loop: the inner-loop is executed sequentially,
and therefore vectorizing reductions in the inner-loop during
- outer-loop vectorization is safe. */
- if (needs_fold_left_reduction_p (scalar_type, orig_code))
+ outer-loop vectorization is safe. Likewise when we are vectorizing
+ a series of reductions using SLP and the VF is one the reductions
+ are performed in scalar order. */
+ if (slp_node
+ && !REDUC_GROUP_FIRST_ELEMENT (stmt_info)
+ && known_eq (LOOP_VINFO_VECT_FACTOR (loop_vinfo), 1u))
+ ;
+ else if (needs_fold_left_reduction_p (scalar_type, orig_code))
{
/* When vectorizing a reduction chain w/o SLP the reduction PHI
is not directy used in stmt. */