Comments
Patch
===================================================================
@@ -1704,7 +1704,7 @@ vect_is_slp_reduction (loop_vec_info loop_info, gi
tree lhs;
imm_use_iterator imm_iter;
use_operand_p use_p;
- int nloop_uses, size = 0;
+ int nloop_uses, size = 0, nuses;
bool found = false;
if (loop != vect_loop)
@@ -1715,9 +1715,11 @@ vect_is_slp_reduction (loop_vec_info loop_info, gi
while (1)
{
nloop_uses = 0;
+ nuses = 0;
FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs)
{
use_stmt = USE_STMT (use_p);
+ nuses++;
if (is_gimple_debug (use_stmt))
continue;
@@ -1739,6 +1741,10 @@ vect_is_slp_reduction (loop_vec_info loop_info, gi
return false;
}
+ /* We reached a statement with no uses. */
+ if (nuses == 0)
+ return false;
+
if (found)
break;
===================================================================
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+
+static char func2() { }
+
+struct S0
+{
+ int t;
+};
+
+int g;
+
+struct S0 s0;
+
+int
+foo (int arg)
+{
+ int *ptr = &g;
+ int i, j;
+ for (i = 0; i < 10; i += 1)
+ {
+ for (j = 0; j < 1; j += 1)
+ {
+ int k;
+ if (arg)
+ {
+ int l;
+ for (k = 1; arg < 10; arg = func2 ())
+ {
+ return l;
+ }
+ }
+ *ptr = func2 () ^ s0.t;
+ }
+ }
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */