aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDorit Nuzman <dorit@il.ibm.com>2007-02-12 13:14:52 +0000
committerDorit Nuzman <dorit@gcc.gnu.org>2007-02-12 13:14:52 +0000
commit9b3ffe5f7a7adb9d541c976e36e1e0da94506506 (patch)
treee603124bde74fd9d2dfcbd602643a9464d62b175
parent27f33b1531f5e59660355565e056a6630eafd762 (diff)
downloadgcc-9b3ffe5f7a7adb9d541c976e36e1e0da94506506.zip
gcc-9b3ffe5f7a7adb9d541c976e36e1e0da94506506.tar.gz
gcc-9b3ffe5f7a7adb9d541c976e36e1e0da94506506.tar.bz2
re PR tree-optimization/29145 (unsafe use of restrict qualifier)
PR tree-optimization/29145 * tree-data-ref.c (base_addr_differ_p): Make us more conservative in our handling of restrict qualified pointers. From-SVN: r121844
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr29145.c48
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-74.c11
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-80.c10
-rw-r--r--gcc/tree-data-ref.c20
6 files changed, 92 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c21e25f..3e65ea4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6ef96fe..822bcff 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..97d190c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr29145.c
@@ -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" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-74.c b/gcc/testsuite/gcc.dg/vect/vect-74.c
index f9095e8..0815512 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-74.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-74.c
@@ -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" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-80.c b/gcc/testsuite/gcc.dg/vect/vect-80.c
index 3696b52..916935c 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-80.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-80.c
@@ -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" } } */
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index 794bb83..d49d682 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -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;
}