From afa8f0fb33f62b3e9ea2fad0813372730d18295b Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Sat, 11 Nov 2006 17:10:56 -0800 Subject: [PATCH] re PR rtl-optimization/28812 (RTL aliasing vs may_alias and structs) 2006-11-11 Andrew Pinski PR rtl-opt/28812 * alias.c (fixed_scalar_and_varying_struct_p): Don't return a non null value if the struct memory access is in the 0th aliasing set. 2006-11-11 Andrew Pinski PR rtl-opt/28812 * gcc.c-torture/execute/mayalias-3.c: New test. From-SVN: r118716 --- gcc/ChangeLog | 7 +++++ gcc/alias.c | 6 +++-- gcc/testsuite/ChangeLog | 11 +++++--- .../gcc.c-torture/execute/mayalias-3.c | 27 +++++++++++++++++++ 4 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/mayalias-3.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 05358b10010e..3cca0dcc2d36 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2006-11-11 Andrew Pinski + + PR rtl-opt/28812 + * alias.c (fixed_scalar_and_varying_struct_p): Don't return a + non null value if the struct memory access is in the 0th + aliasing set. + 2006-11-12 Jie Zhang Revert diff --git a/gcc/alias.c b/gcc/alias.c index 7c51ad79dd60..d027b79a053e 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -1857,13 +1857,15 @@ fixed_scalar_and_varying_struct_p (rtx mem1, rtx mem2, rtx mem1_addr, if (! flag_strict_aliasing) return NULL_RTX; - if (MEM_SCALAR_P (mem1) && MEM_IN_STRUCT_P (mem2) + if (MEM_ALIAS_SET (mem2) + && MEM_SCALAR_P (mem1) && MEM_IN_STRUCT_P (mem2) && !varies_p (mem1_addr, 1) && varies_p (mem2_addr, 1)) /* MEM1 is a scalar at a fixed address; MEM2 is a struct at a varying address. */ return mem1; - if (MEM_IN_STRUCT_P (mem1) && MEM_SCALAR_P (mem2) + if (MEM_ALIAS_SET (mem1) + && MEM_IN_STRUCT_P (mem1) && MEM_SCALAR_P (mem2) && varies_p (mem1_addr, 1) && !varies_p (mem2_addr, 1)) /* MEM2 is a scalar at a fixed address; MEM1 is a struct at a varying address. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index be5d63cebf6a..525ac64774bd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-11-11 Andrew Pinski + + PR rtl-opt/28812 + * gcc.c-torture/execute/mayalias-3.c: New test. + 2006-11-11 Richard Sandiford PR middle-end/27528 @@ -12,8 +17,8 @@ 2006-11-10 Paul Thomas - PR fortran/29758 - * gfortran.dg/reshape_source_size_1.f90: New test. + PR fortran/29758 + * gfortran.dg/reshape_source_size_1.f90: New test. 2006-11-10 Paul Thomas @@ -23,7 +28,7 @@ 2006-11-10 Uros Bizjak PR target/29777 - * lib/target-supports.exp (vect_widen_mult_hi_to_si): Add i?86-*-* + * lib/target-supports.exp (vect_widen_mult_hi_to_si): Add i?86-*-* and x86_64-*-* targets. 2006-11-09 Kaveh R. Ghazi diff --git a/gcc/testsuite/gcc.c-torture/execute/mayalias-3.c b/gcc/testsuite/gcc.c-torture/execute/mayalias-3.c new file mode 100644 index 000000000000..3d667911f4e0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/mayalias-3.c @@ -0,0 +1,27 @@ +struct S { short x; }; +typedef struct S __attribute__((__may_alias__)) test; + +test *p; + +int g(int *a) +{ + p = (test*)a; +} + +int f() +{ + int a; + g(&a); + a = 10; + test s={1}; + *p=s; + return a; +} + +int main() { + if (f() == 10) + __builtin_abort(); + return 0; +} + + -- 2.47.2