aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/ipa/pure-const-2.c
blob: 564a59c20cb85d5747135e96b4791eb44dbd7522 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* { 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 = 0;
  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"} } */