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] Avoid data permutation in strided stores of constants


This is another improvement to interleaved data vectorization for the case
where data permutations can be avoided despite the fact that there are
strided accesses in the code. The first patch (
http://gcc.gnu.org/ml/gcc-patches/2007-01/msg01301.html) handled the case
that all constants are the same, this patch extends it to different
constants.

Despite strided stores in the following loop, there is no need in
permutation of the stored values:

int a[N];
for i
   a[2i] = 2
   a[2i+1] = 3

This patch detects such stores and avoids unnecessary interleaving as shown
in the pseudo vector code snippets below.

Before the patch:

  vect_cst_1 = {2,2,2,2}
  vect_cst_2 = {3,3,3,3}
loop
  vect_inter_high = VEC_INTERLEAVE_HIGH_EXPR <vect_cst_1, vect_cst_2>
  vect_inter_low = VEC_INTERLEAVE_LOW_EXPR <vect_cst_1, vect_cst_2>
  *(vect_a + iv) = vect_inter_high
  iv = iv + 16B
  *(vect_a + iv) = vect_inter_low
  iv = iv + 16B

After the patch:

  vect_cst = {2,3,2,3}
loop
  *(vect_a + iv) = vect_cst
  iv = iv + 16B
  *(vect_a + iv) = vect_cst
  iv = iv + 16B


Bootstrapped and tested on ppc-linux.
Committed to autovect branch.

Ira

ChangeLog entry:

      * tree-vectorizer.h (enum vect_permutation_type): Define.
      (struct _stmt_vec_info): Replace interleaving_not_needed field and
      its access macros with a new field permutation_type. Add more macros
      for access fields related to strided access.
      * tree-vectorizer.c (new_stmt_vec_info): Initialize the new field.
      * tree-vect-analyze.c (vect_analyze_data_ref_access): Detect strided
      stores of not equal constants.
      * tree-vect-transform.c (vect_get_vector_for_operands): New function.
      (vectorizable_store): Use new macros. Minor clean-ups. In case of
      strided store of constant values, call vect_get_vector_for_operands
      to create vectors with the values to store.

The patch (including testcases):
(See attached file: const-patch.txt)

Attachment: const-patch.txt
Description: Text document


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