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
This commit is contained in:
Dorit Nuzman 2007-02-12 13:14:52 +00:00 committed by Dorit Nuzman
parent 27f33b1531
commit 9b3ffe5f7a
6 changed files with 92 additions and 12 deletions

View 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> 2007-02-12 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR middle-end/7651 PR middle-end/7651

View 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> 2007-02-11 H.J. Lu <hongjiu.lu@intel.com>
* gcc.target/i386/sse4a-extract.c: Add "LL" to 64bit constants. * gcc.target/i386/sse4a-extract.c: Add "LL" to 64bit constants.

View File

@ -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" } } */

View File

@ -42,8 +42,11 @@ int main (void)
return 0; return 0;
} }
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ /* Xfail until handling restrict is refined. See pr29145 */
/* { 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 *-*-* } } } */
/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { xfail vect_no_align } } } */ /* Uncomment when this testcase gets vectorized again:
/* { 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 "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" } } */ /* { dg-final { cleanup-tree-dump "vect" } } */

View File

@ -47,8 +47,10 @@ int main (void)
all three accesses (peeling to align the store will not force the all three accesses (peeling to align the store will not force the
two loads to be aligned). */ two loads to be aligned). */
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { xfail vect_no_align } } } */ /* Uncomment when this testcase gets vectorized again:
/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail 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 versioning." 3 "vect" { target 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" } } */ /* { dg-final { cleanup-tree-dump "vect" } } */

View File

@ -490,6 +490,7 @@ base_addr_differ_p (struct data_reference *dra,
tree addr_a = DR_BASE_ADDRESS (dra); tree addr_a = DR_BASE_ADDRESS (dra);
tree addr_b = DR_BASE_ADDRESS (drb); tree addr_b = DR_BASE_ADDRESS (drb);
tree type_a, type_b; tree type_a, type_b;
tree decl_a, decl_b;
bool aliased; bool aliased;
if (!addr_a || !addr_b) 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 /* An instruction writing through a restricted pointer is "independent" of any
instruction reading or writing through a different pointer, in the same instruction reading or writing through a different restricted pointer,
block/scope. */ in the same block/scope. */
else if ((TYPE_RESTRICT (type_a) && !DR_IS_READ (dra)) else if (TYPE_RESTRICT (type_a)
|| (TYPE_RESTRICT (type_b) && !DR_IS_READ (drb))) && 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; *differ_p = true;
return true; return true;
} }
return false; return false;
} }