Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2019-10-21  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/92162
        * tree-vect-loop.c (vect_create_epilog_for_reduction): Lookup
        STMT_VINFO_REDUC_IDX in reduc_info.
        * tree-vect-stmts.c (vectorizable_condition): Likewise.

        * gcc.dg/pr92162.c: New testcase.

Index: gcc/testsuite/gcc.dg/pr92162.c
===================================================================
--- gcc/testsuite/gcc.dg/pr92162.c      (nonexistent)
+++ gcc/testsuite/gcc.dg/pr92162.c      (working copy)
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast" } */
+
+short int s8;
+
+void __attribute__ ((simd))
+gn (void)
+{
+  s8 = 0;
+}
Index: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c        (revision 277242)
+++ gcc/tree-vect-loop.c        (working copy)
@@ -4259,9 +4259,9 @@ vect_create_epilog_for_reduction (stmt_v
         (CCOMPARE).  The then and else values mirror the main VEC_COND_EXPR:
         the reduction phi corresponds to NEW_PHI_TREE and the new values
         correspond to INDEX_BEFORE_INCR.  */
-      gcc_assert (STMT_VINFO_REDUC_IDX (stmt_info) >= 1);
+      gcc_assert (STMT_VINFO_REDUC_IDX (reduc_info) >= 1);
       tree index_cond_expr;
-      if (STMT_VINFO_REDUC_IDX (stmt_info) == 2)
+      if (STMT_VINFO_REDUC_IDX (reduc_info) == 2)
        index_cond_expr = build3 (VEC_COND_EXPR, cr_index_vector_type,
                                  ccompare, indx_before_incr, new_phi_tree);
       else
Index: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c       (revision 277242)
+++ gcc/tree-vect-stmts.c       (working copy)
@@ -9818,7 +9818,7 @@ vectorizable_condition (stmt_vec_info st
        return false;
       reduc_info = info_for_reduction (stmt_info);
       reduction_type = STMT_VINFO_REDUC_TYPE (reduc_info);
-      reduc_index = STMT_VINFO_REDUC_IDX (stmt_info);
+      reduc_index = STMT_VINFO_REDUC_IDX (reduc_info);
       gcc_assert (reduction_type != EXTRACT_LAST_REDUCTION
                  || reduc_index != -1);
     }

Reply via email to