summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/graphite/pr35356-2.c
blob: 66cfdea5aefecac046b42e24a0041898d8ac28e4 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* { dg-options "-O2 -fgraphite-identity -fdump-tree-graphite-all" } */

int a[100];

int
foo (int bar, int n, int k)
{
  int i;

  for (i = 0; i < n; i++)
    if (i == k)
      a[i] = 1;
    else 
      a[i] = i;

  return a[bar];
}

/* We should generate the following:

   | for (i = 0; i < min (n, k); i++)
   |   a[i] = i;
   | if (k >= 0 && k < n)
   |   a[k] = 1;
   | for (i = max(k+1,0); i < n; i++)
   |   a[i] = i;

   XXX: At the moment we generate to protect loops that are executed zero times.

   | if (0 < min (n, k) + 1)
   |   for (i = 0; i < min (n, k); i++)
   |     a[i] = i;
   | if (k >= 0 && k < n)
   |   a[k] = 1;
   | if (0 < max(n, k) + 1)
   |   for (i = max(k+1,0); i < n; i++)
   |     a[i] = i;

*/


/* { dg-final { scan-tree-dump-times "MIN_EXPR" 4 "graphite" } } */
/* { dg-final { scan-tree-dump-times "MAX_EXPR" 4 "graphite" } } */
/* { dg-final { cleanup-tree-dump "graphite" } } */