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]

Re: [autovect] unknown alignment and loop peeling


Devang Patel <dpatel@apple.com> wrote on 21/02/2006 23:58:49:

> Hello,
>
>
> This patch adds target to handle unknown alignment. It does not add
> runtime test yet.

(Just for the record - related discussion/PR:
http://gcc.gnu.org/ml/gcc/2005-12/msg00390.html)

> Many vectorizer tests fail for platforms that do
> not define this new target hook. These tests rely on unknown, but
> safe for peeling, alignment. This patch includes target hook for
> powerpc-apple-darwin.
>

I'd much rather if we didn't create a situation in which so many testcases
are failing. How about providing a default implementation to the target
hook to more or less preserve the current behavior? I'm attaching a
suggestion. It's actually more conservative than the current behavior of
the vectorizer.
Same comment about the rs6000 implementation. Suggestions for a better
(more/less conservative) implementation of the hook for other rs6000
targets are welcome.  Attached is a diff relative to your patch, and a diff
relative to the branch.

As for the new testcases: I think what you really want to check is whether
peeling took place or not, rather than (or in addition to) whether the loop
was vectorized or not. I would change the testcases as follows (also added
a bit of documentation, and the cleanup-tree-dump directive):

--- vect-align-1.c.devang       2006-02-23 08:58:25.921354888 +0200
+++ vect-align-1.c      2006-02-23 09:06:22.424334976 +0200
@@ -13,6 +13,10 @@

 struct foo p2;
 int x[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
+
+/* Compile time known misalignment. Cannot use loop peeling to align
+   the store.  */
+
 int
 main1 (struct foo *p)
 {
@@ -43,5 +47,7 @@
   return 0;
 }

-/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "Alignment of access forced using
peeling" 0 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail
*-*-* } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */

--- vect-align-2.c.devang       2006-02-23 08:58:50.644324424 +0200
+++ vect-align-2.c      2006-02-23 09:13:06.936347376 +0200
@@ -14,6 +14,9 @@
 struct foo f2;
 int z[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};

+/* Compile time unknown misalignment. Cannot use loop peeling to align
+   the store.  */
+
 void fbar(struct foo *fp)
 {
   int i,j;
@@ -35,6 +38,7 @@
   return 0;
 }

+/* { dg-final { scan-tree-dump-times "Alignment of access forced using
peeling" 0 "vect" } } */
+/* { dg-final { scan-tree-dump-times "Alignment of access forced using
versioning" 1 "vect" } } */
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
-
-
+/* { dg-final { cleanup-tree-dump "vect" } } */


With the proposed changes, I think all vectorizer testcases are supposed to
pass (but I tested only on powerpc-linux and I haven't bootstrapped with
these changes).

A few minor nits:

Index: gcc/testsuite/gcc.dg/vect/vect-28.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-28.c   (revision 111308)
+++ gcc/testsuite/gcc.dg/vect/vect-28.c   (working copy)
@@ -11,6 +11,7 @@
 int main1 (int off)
 {
   int i;
+
   int ia[N+OFF];

   for (i = 0; i < N; i++)

you probably didn't mean to include that in your patch?

Index: gcc/tree-vect-analyze.c
===================================================================
--- gcc/tree-vect-analyze.c   (revision 111308)
+++ gcc/tree-vect-analyze.c   (working copy)
@@ -1451,6 +1451,45 @@
        && DR_GROUP_FIRST_DR (stmt_info) != stmt)
      continue;

+      /* If misalignment is known at the compiler time then apply peeling
+      only if natural alignment is reachable through peeling.  */
+      if (known_alignment_for_access_p (dr)
+       && !aligned_access_p (dr))
+     {
+       tree vectype = STMT_VINFO_VECTYPE (stmt_info);
+       HOST_WIDE_INT elm_size_b = int_cst_value (TYPE_SIZE_UNIT (TREE_TYPE
(vectype)));

> new line missing

+       if (DR_MISALIGNMENT (dr) % elm_size_b)
+         {
+           do_peeling = false;
+           break;
+         }
+     }
+
+      if (!known_alignment_for_access_p (dr))
+     {
+       tree base_type;
+       tree type = (TREE_TYPE (DR_REF (dr)));
+       tree ba = DR_BASE_OBJECT (dr);
+       bool is_packed = false;

> new line missing

thanks,
dorit

(See attached file: peeling.branchpatch.txt)(See attached file:
peeling.diff.txt)

Attachment: peeling.branchpatch.txt
Description: Text document

Attachment: peeling.diff.txt
Description: Text document


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