On Mon, Jul 25, 2011 at 2:05 AM, Richard Guenther <richard.guent...@gmail.com> wrote: > On Mon, Jul 25, 2011 at 1:34 AM, Andrew Pinski <pins...@gmail.com> wrote: >> Hi, >> There are two issues, first the inliner does not copy a volatile >> when creating a new tree in one case. The second issue is that >> IPA-SRA does not check if we are deferencing a pointer variable via a >> volatile type. >> >> OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. > > Ok. > > Can you add a testcase?
Yes Here are the testcases I added: Index: testsuite/gcc.dg/tree-ssa/pr49671-1.c =================================================================== --- testsuite/gcc.dg/tree-ssa/pr49671-1.c (revision 0) +++ testsuite/gcc.dg/tree-ssa/pr49671-1.c (revision 0) @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +volatile int t; +static inline int cvmx_atomic_get32(volatile int *ptr) +{ + return *ptr; +} +void f(void) +{ + while (!cvmx_atomic_get32(&t)) + ; +} + +/* { dg-final { scan-tree-dump "\{v\}" "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ + + Index: testsuite/gcc.dg/tree-ssa/pr49671-2.c =================================================================== --- testsuite/gcc.dg/tree-ssa/pr49671-2.c (revision 0) +++ testsuite/gcc.dg/tree-ssa/pr49671-2.c (revision 0) @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +int t; +static inline int cvmx_atomic_get32(int *ptr) +{ + return *(volatile int*)ptr; +} +void f(void) +{ + while (!cvmx_atomic_get32(&t)) + ; +} + +/* { dg-final { scan-tree-dump "\{v\}" "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ + + Thanks, Andrew Pinski