1 /* { dg-do compile } */ 2 /* { dg-options "-O3 -fdump-tree-local-pure-const1 -fdump-tree-optimized" } */ 3 static __attribute__ ((noinline, noclone)) i_am_pure(char * c,int n)4int i_am_pure(char *c, int n) 5 { 6 char *d=__builtin_alloca (n); 7 int i; 8 int sum; 9 for (i=0;i<n;i++) 10 d[i] = c[i]; 11 for (i=0;i<n;i++) 12 d[i] *= c[n-i]; 13 for (i=0;i<n;i++) 14 sum+=d[i]; 15 if (sum) 16 __builtin_unreachable (); 17 return sum; 18 } 19 char array[11]; 20 int main(void)21main(void) 22 { 23 i_am_pure (array,5); 24 i_am_pure (array,11); 25 return 0; 26 } 27 /* { dg-final { scan-tree-dump "found to be pure: i_am_pure" "local-pure-const1"} } */ 28 /* { dg-final { scan-tree-dump-not "i_am_pure" "optimized"} } */ 29 /* { dg-final { cleanup-tree-dump "local-pure-const1" } } */ 30 /* { dg-final { cleanup-tree-dump "optimized" } } */ 31