+2018-08-22 Richard Sandiford <richard.sandiford@arm.com>
+
+ PR tree-optimization/86725
+ * tree-vect-loop.c (vect_inner_phi_in_double_reduction_p): New
+ function.
+ (vect_analyze_scalar_cycles_1): Check it.
+
2018-08-22 Richard Sandiford <richard.sandiford@arm.com>
PR tree-optimization/86725
+2018-08-22 Richard Sandiford <richard.sandiford@arm.com>
+
+ PR tree-optimization/86725
+ * gcc.dg/vect/no-scevccp-pr86725-2.c: New test.
+ * gcc.dg/vect/no-scevccp-pr86725-3.c: Likewise.
+ * gcc.dg/vect/no-scevccp-pr86725-4.c: Likewise.
+ * gcc.dg/vect/no-scevccp-pr86725-5.c: Likewise.
+
2018-08-22 Richard Sandiford <richard.sandiford@arm.com>
PR tree-optimization/86725
--- /dev/null
+/* { dg-do compile } */
+/* { dg-additional-options "-O -w" } */
+
+int
+nr (int xe)
+{
+ int oo, wo = 0;
+
+ for (oo = 0; oo < 4; ++oo)
+ {
+ int qq;
+
+ for (qq = 0; qq < 2; ++qq)
+ {
+ wo += 0x80000000;
+ xe += wo;
+ }
+ }
+ return xe;
+}
+
+/* { dg-final { scan-tree-dump "reduction used in loop" "vect" { target vect_int } } } */
+/* { dg-final { scan-tree-dump-not "OUTER LOOP VECTORIZED" "vect" } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-additional-options "-O -w" } */
+
+int foo;
+int
+nr (int xe)
+{
+ int oo, wo = 0;
+
+ for (oo = 0; oo < 4; ++oo)
+ {
+ int qq;
+
+ for (qq = 0; qq < 2; ++qq)
+ {
+ wo += 0x80000000;
+ xe += wo;
+ }
+ }
+ foo = wo;
+ return xe;
+}
+
+/* { dg-final { scan-tree-dump "reduction used in loop" "vect" { target vect_int } } } */
+/* { dg-final { scan-tree-dump-not "OUTER LOOP VECTORIZED" "vect" } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-additional-options "-O -w" } */
+
+int
+nr (unsigned int xe, unsigned int qqn)
+{
+ unsigned int oo, wo = 0;
+
+ for (oo = 0; oo < 4; ++oo)
+ {
+ unsigned int qq = qqn;
+ do
+ {
+ wo += 1;
+ xe += wo;
+ }
+ while (qq-- > 0);
+ }
+ return xe;
+}
+
+/* { dg-final { scan-tree-dump "reduction used in loop" "vect" { target vect_int } } } */
+/* { dg-final { scan-tree-dump-not "OUTER LOOP VECTORIZED" "vect" } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-additional-options "-O -w" } */
+
+unsigned int foo;
+int
+nr (unsigned int xe, unsigned int qqn)
+{
+ unsigned int oo, wo = 0;
+
+ for (oo = 0; oo < 4; ++oo)
+ {
+ unsigned int qq = qqn;
+ do
+ {
+ wo += 1;
+ xe += qq;
+ }
+ while (qq-- > 0);
+ }
+ foo = wo;
+ return xe;
+}
+
+/* { dg-final { scan-tree-dump "OUTER LOOP VECTORIZED" "vect" { target vect_int } } } */
return true;
}
+/* Return true if PHI, described by STMT_INFO, is the inner PHI in
+ what we are assuming is a double reduction. For example, given
+ a structure like this:
+
+ outer1:
+ x_1 = PHI <x_4(outer2), ...>;
+ ...
+
+ inner:
+ x_2 = PHI <x_1(outer1), ...>;
+ ...
+ x_3 = ...;
+ ...
+
+ outer2:
+ x_4 = PHI <x_3(inner)>;
+ ...
+
+ outer loop analysis would treat x_1 as a double reduction phi and
+ this function would then return true for x_2. */
+
+static bool
+vect_inner_phi_in_double_reduction_p (stmt_vec_info stmt_info, gphi *phi)
+{
+ loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info);
+ use_operand_p use_p;
+ ssa_op_iter op_iter;
+ FOR_EACH_PHI_ARG (use_p, phi, op_iter, SSA_OP_USE)
+ if (stmt_vec_info def_info = loop_vinfo->lookup_def (USE_FROM_PTR (use_p)))
+ if (STMT_VINFO_DEF_TYPE (def_info) == vect_double_reduction_def)
+ return true;
+ return false;
+}
+
/* Function vect_analyze_scalar_cycles_1.
Examine the cross iteration def-use cycles of scalar variables
}
if (!access_fn
+ || vect_inner_phi_in_double_reduction_p (stmt_vinfo, phi)
|| !vect_is_simple_iv_evolution (loop->num, access_fn, &init, &step)
|| (LOOP_VINFO_LOOP (loop_vinfo) != loop
&& TREE_CODE (step) != INTEGER_CST))