diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/ipa/pure-const-2.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/ipa/pure-const-2.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/ipa/pure-const-2.c b/gcc/testsuite/gcc.dg/ipa/pure-const-2.c new file mode 100644 index 000000000..2dcca18c0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pure-const-2.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-local-pure-const1 -fdump-tree-optimized" } */ +static __attribute__ ((noinline, noclone)) +int i_am_pure(char *c, int n) +{ + char *d=__builtin_alloca (n); + int i; + int sum; + for (i=0;i<n;i++) + d[i] = c[i]; + for (i=0;i<n;i++) + d[i] *= c[n-i]; + for (i=0;i<n;i++) + sum+=d[i]; + if (sum) + __builtin_unreachable (); + return sum; +} +char array[11]; +int +main(void) +{ + i_am_pure (array,5); + i_am_pure (array,11); + return 0; +} +/* { dg-final { scan-tree-dump "found to be pure: i_am_pure" "local-pure-const1"} } */ +/* { dg-final { scan-tree-dump-not "i_am_pure" "optimized"} } */ +/* { dg-final { cleanup-tree-dump "local-pure-const1" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ |