This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[autovect][patch]Loop Versioning for Vectorization


Add loop versioning for vectorization.  For example:

for(i=0; i<N; ++i)
{
  pa[i] = pb[i] + pc[i];
}

If the alignment of the pointers pa, pb, and pc cannot be determined at 
compile time
then a runtime test can be inserted to check alignment and direct control 
to either a
vector version or a scalar version of the loop.  At a high level it might 
look something
like:

if ((&pa[0] % AlignConst == 0)
    && (&pb[0] % AlignConst == 0)
    && (&pc[0] % AlignConst == 0))
  {
    for(i=0; i<N/VectorizationFactor; ++i)
      {
        vpa[i] = vpb[i] + vpc[i];
      }
  }
else
  {
    for(i=0; i<N; ++i)
      {
        pa[i] = pb[i] + pc[i];
      }
  }

The constants AlignConst and VectorizationFactor are machine dependent. 
For example,
if a vector is required to be aligned on a 16 byte boundary then 
AlignConst would be
16.  If a vector vpa[i] contains 4 elements of pa[i] then 
VectorizationFactor would be 4.

Tested on ppc
No differences in make check or in SPEC.

OK for autovect branch?

Keith.


Changelog:
        * tree-vectorizer.c (new_loop_vec_info): Initialize 
LOOP_VINFO_MAY_MISALIGN_STMTS.
        (destroy_loop_vec_info); varray_clear  of 
LOOP_VINFO_MAY_MISALIGN_STMTS.
        (vect_create_cond_for_align_checks): New.
        (vect_transform_loop): Add calls to tree_ssa_loop_version and
        vect_create_cond_for_align_checks.
        (vect_build_dist_vector): Change loop_info to loop_vinfo as it is 
called elsewhere.
        (vect_update_misalignment_for_peel): New.  Holds multiple use 
code.
        (vect_enhance_data_refs_alignment): Decide when to do loop 
versioning and
        update data structcures.
        (vect_analyze_data_refs_alignment): Fix comment.
        (vect_pattern_recog): Fix comment.
        (vectorize_loops): Move call to rewrite_into_loop_closed_ssa so 
it's done each
        time it's needed rather than once at the end.
        *tree-vectorizer.h(struct _loop_vec_info): Add fields ptr_mask and
        may_misalign_stmts.
        (MAX_RUNTIME_ALIGNMENT_CHECKS): New named constant.

Attachment: vect.1-21.diff
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]