--- /dev/null
+/* { dg-do compile } */
+
+long g_2205, g_3005;
+int g_3320;
+void main()
+{
+ for (; g_2205; g_2205 += 1)
+ {
+ g_3005 = 0;
+ for (; g_3005 <= 8; g_3005 += 1)
+ g_3320 &= 611 & (unsigned char)g_3005;
+ }
+}
+
+/* { dg-final { scan-tree-dump-not "failed to update reduction index" "vect" } } */
{
bool found = false;
if (gimple_extract_op (s, &op))
- for (unsigned i = 0; i < op.num_ops; ++i)
- if (op.ops[i] == lookfor)
+ {
+ for (unsigned i = 0; i < op.num_ops; ++i)
+ if (op.ops[i] == lookfor)
+ {
+ STMT_VINFO_REDUC_IDX (vinfo->lookup_stmt (s)) = i;
+ lookfor = gimple_get_lhs (s);
+ found = true;
+ break;
+ }
+ /* Try harder to find a mid-entry into an earlier pattern
+ sequence. This means that the initial 'lookfor' was
+ bogus. */
+ if (!found)
{
- STMT_VINFO_REDUC_IDX (vinfo->lookup_stmt (s)) = i;
- lookfor = gimple_get_lhs (s);
- found = true;
- break;
+ for (unsigned i = 0; i < op.num_ops; ++i)
+ if (TREE_CODE (op.ops[i]) == SSA_NAME)
+ if (auto def = vinfo->lookup_def (op.ops[i]))
+ if (vect_is_reduction (def))
+ {
+ STMT_VINFO_REDUC_IDX (vinfo->lookup_stmt (s)) = i;
+ lookfor = gimple_get_lhs (s);
+ found = true;
+ break;
+ }
}
+ }
if (s == pattern_stmt)
{
if (!found && dump_enabled_p ())