[patch, vectorizer] Fix PR tree-optimization/38529

Daniel Berlin dberlin@dberlin.org
Mon Dec 29 17:22:00 GMT 2008


On Tue, Dec 16, 2008 at 7:05 AM, Ira Rosen <IRAR@il.ibm.com> wrote:
>
> Hi,
>
> This patch fixes an ICE in the vectorizer that occurs in case that a def is
> in the inner loop and its use is in the outer loop (which is being
> vectorized). The problem is that the vectorized definitions were not
> recorded for such uses.
>
> Bootstrapped with vectorization enabled and regtested on
> powerpc64-suse-linux.
> O.K. for 4.3 and 4.4?
>
> Thanks,
> Ira
>
> ChangeLog entry:
>
> 2008-12-16  Dorit Nuzman  <dorit@il.ibm.com>
>            Ira Rosen  <irar@il.ibm.com>
>
>      PR tree-optimization/38529
>      * tree-vect-transform (vect_transform_stmt): Handle inner-loop stmts
>      whose DEF is used in the loop-nest that is being vectorized, but
> outside
>      the immediately enclosing loop.
>
> testsuite/ChangeLog entry:
>
> 2008-12-16  Dorit Nuzman  <dorit@il.ibm.com>
>            Ira Rosen  <irar@il.ibm.com>
>
>      PR tree-optimization/38529
>      * gcc.dg/vect/pr38529.c: New.
>
>
> Index: tree-vect-transform.c
> ===================================================================
> --- tree-vect-transform.c       (revision 142762)
> +++ tree-vect-transform.c       (working copy)
> @@ -7047,6 +7047,8 @@ vect_transform_stmt (gimple stmt, gimple
>   stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
>   gimple orig_stmt_in_pattern;
>   bool done;
> +  loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info);
> +  struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
>
>   switch (STMT_VINFO_TYPE (stmt_info))
>     {
> @@ -7130,6 +7132,52 @@ vect_transform_stmt (gimple stmt, gimple;
>        }
>     }
>
> +  /* Handle inner-loop stmts whose DEF is used in the loop-nest that
> +     is being vectorized, but outside the immediately enclosing loop.  */
> +  if (vec_stmt
> +      && nested_in_vect_loop_p (loop, stmt)
> +      && STMT_VINFO_TYPE (stmt_info) != reduc_vec_info_type
> +      && (STMT_VINFO_RELEVANT (stmt_info) == vect_used_in_outer
> +          || STMT_VINFO_RELEVANT (stmt_info) ==
> vect_used_in_outer_by_reduction))
> +    {
> +      struct loop *innerloop = loop->inner;)
> +      imm_use_iterator imm_iter;
> +      use_operand_p use_p;
> +      VEC(gimple,heap) *phis = NULL;>
> +      tree scalar_dest;
> +      gimple exit_phi;;
> +      int i;
> +
> +      if (vect_print_dump_info (REPORT_DETAILS))
> +       fprintf (vect_dump, "Record the vdef for outer-loop
> vectorization.");
> +
> +      /* Find the relevant loop-exit phi-node, and reord the vec_stmt
> there;
> +        (to be used when vectorizing outer-loop stmts that use the DEF of
> +        STMT).  */
> +      if (gimple_code (stmt) == GIMPLE_PHI)
> +       scalar_dest = PHI_RESULT (stmt);
> +      else
> +        scalar_dest = gimple_assign_lhs (stmt);
> +
> +      phis = VEC_alloc (gimple, heap, 10);
> +      FOR_EACH_IMM_USE_FAST (use_p, imm_iter, scalar_dest)
> +       {
> +         if (!flow_bb_inside_loop_p (innerloop, gimple_bb (USE_STMT
> (use_p))))
> +           {
> +             exit_phi = USE_STMT (use_p);
> +             VEC_quick_push (gimple, phis, exit_phi);
> +           }
> +       }
> +
> +      for (i = 0; VEC_iterate (gimple, phis, i, exit_phi); i++)
> +       {
> +         stmt_vec_info stmt_vinfo = vinfo_for_stmt (exit_phi);)
> +         STMT_VINFO_VEC_STMT (stmt_vinfo) = vec_stmt;
> +        }
> +    }
> +

Am i missing the reason you bother to push these onto a vector?
Why not do:
> +         stmt_vec_info stmt_vinfo = vinfo_for_stmt (exit_phi);)
> +         STMT_VINFO_VEC_STMT (stmt_vinfo) = vec_stmt;

inside the loop you are pushing onto the vector, and remove the entire
vector pushing/etc



More information about the Gcc-patches mailing list