PR tree-optimization/29145
authordorit <dorit@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 12 Feb 2007 13:14:52 +0000 (13:14 +0000)
committerdorit <dorit@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 12 Feb 2007 13:14:52 +0000 (13:14 +0000)
        * tree-data-ref.c (base_addr_differ_p): Make us more conservative
        in our handling of restrict qualified pointers.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121844 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr29145.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/vect-74.c
gcc/testsuite/gcc.dg/vect/vect-80.c
gcc/tree-data-ref.c

index c21e25f..3e65ea4 100644 (file)
@@ -1,3 +1,9 @@
+2007-02-12  Dorit Nuzman  <dorit@il.ibm.com>
+
+       PR tree-optimization/29145
+       * tree-data-ref.c (base_addr_differ_p): Make us more conservative
+       in our handling of restrict qualified pointers.
+
 2007-02-12  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
 
        PR middle-end/7651
index 6ef96fe..822bcff 100644 (file)
@@ -1,3 +1,12 @@
+2007-02-12  Dorit Nuzman  <dorit@il.ibm.com>
+
+       PR tree-optimization/29145
+       * gcc.dg/vect/vect-74.c: Xfail the test - cannot be vectorized until
+       alias analysis is improved to take better advantage of restrict
+       qualified pointers.
+       * gcc.dg/vect/vect-80.c: Likewise.
+       * gcc.dg/vect/pr29145.c: New.
+
 2007-02-11  H.J. Lu  <hongjiu.lu@intel.com>
 
        * gcc.target/i386/sse4a-extract.c: Add "LL" to 64bit constants.
diff --git a/gcc/testsuite/gcc.dg/vect/pr29145.c b/gcc/testsuite/gcc.dg/vect/pr29145.c
new file mode 100644 (file)
index 0000000..97d190c
--- /dev/null
@@ -0,0 +1,48 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+void with_restrict(int * __restrict p)
+{
+  int i;
+  int *q = p - 2;
+
+  for (i = 0; i < 1000; ++i) {
+    p[i] = q[i];
+  }
+}
+
+void without_restrict(int * p)
+{
+  int i;
+  int *q = p - 2;
+
+  for (i = 0; i < 1000; ++i) {
+    p[i] = q[i];
+  }
+}
+
+int main(void)
+{
+  int i;
+  int a[1002];
+  int b[1002];
+
+  for (i = 0; i < 1002; ++i) {
+    a[i] = b[i] = i;
+  }
+
+  with_restrict(a + 2);
+  without_restrict(b + 2);
+
+  for (i = 0; i < 1002; ++i) {
+    if (a[i] != b[i])
+      abort();
+  }
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 2 "vect"  } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
index f9095e8..0815512 100644 (file)
@@ -42,8 +42,11 @@ int main (void)
   return 0;    
 }
 
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
-/*  { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 3 "vect" { target vect_no_align } } } */
-/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { xfail vect_no_align } } } */
-/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail vect_no_align } } } */
+/* Xfail until handling restrict is refined.  See pr29145 */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
+/* Uncomment when this testcase gets vectorized again:    
+ dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 3 "vect" { target vect_no_align } } 
+ dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { xfail vect_no_align } } 
+ dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail vect_no_align } }  
+*/
 /* { dg-final { cleanup-tree-dump "vect" } } */
index 3696b52..916935c 100644 (file)
@@ -47,8 +47,10 @@ int main (void)
    all three accesses (peeling to align the store will not force the
    two loads to be aligned).  */
 
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
-/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { xfail vect_no_align } } } */
-/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail vect_no_align } } } */
-/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 3 "vect" { target vect_no_align } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
+/* Uncomment when this testcase gets vectorized again:
+ dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { xfail vect_no_align } } 
+ dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail vect_no_align } } 
+ dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 3 "vect" { target vect_no_align } } 
+*/
 /* { dg-final { cleanup-tree-dump "vect" } } */
index 794bb83..d49d682 100644 (file)
@@ -490,6 +490,7 @@ base_addr_differ_p (struct data_reference *dra,
   tree addr_a = DR_BASE_ADDRESS (dra);
   tree addr_b = DR_BASE_ADDRESS (drb);
   tree type_a, type_b;
+  tree decl_a, decl_b;
   bool aliased;
 
   if (!addr_a || !addr_b)
@@ -547,14 +548,25 @@ base_addr_differ_p (struct data_reference *dra,
     }
   
   /* An instruction writing through a restricted pointer is "independent" of any 
-     instruction reading or writing through a different pointer, in the same 
-     block/scope.  */
-  else if ((TYPE_RESTRICT (type_a) && !DR_IS_READ (dra))
-      || (TYPE_RESTRICT (type_b) && !DR_IS_READ (drb)))
+     instruction reading or writing through a different restricted pointer, 
+     in the same block/scope.  */
+  else if (TYPE_RESTRICT (type_a)
+          &&  TYPE_RESTRICT (type_b) 
+          && (!DR_IS_READ (drb) || !DR_IS_READ (dra))
+          && TREE_CODE (DR_BASE_ADDRESS (dra)) == SSA_NAME
+          && (decl_a = SSA_NAME_VAR (DR_BASE_ADDRESS (dra)))
+          && TREE_CODE (decl_a) == PARM_DECL
+          && TREE_CODE (DECL_CONTEXT (decl_a)) == FUNCTION_DECL
+          && TREE_CODE (DR_BASE_ADDRESS (drb)) == SSA_NAME
+          && (decl_b = SSA_NAME_VAR (DR_BASE_ADDRESS (drb)))
+          && TREE_CODE (decl_b) == PARM_DECL
+          && TREE_CODE (DECL_CONTEXT (decl_b)) == FUNCTION_DECL
+          && DECL_CONTEXT (decl_a) == DECL_CONTEXT (decl_b)) 
     {
       *differ_p = true;
       return true;
     }
+
   return false;
 }