2018-04-30 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / predcom-dse-8.c
blob45ffd25c424e965d805672f4220ac864c9943623
1 /* { dg-do run } */
2 /* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
4 int arr[105] = {2, 3, 5, 7, 11, 13, 17, 19};
5 int result0[10] = {2, 3, 5, 7, 11, 13, 17, 19};
6 int result1[10] = {0, 3, 5, 7, 11, -5, 17, 19};
7 int result2[10] = {0, 0, 5, 7, 11, -5, -5, 19};
8 int result3[10] = {0, 0, 0, 7, 11, -5, -5, -5};
9 int result4[10] = {0, 0, 0, 0, 11, -5, -5, -5, -5};
10 int result100[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
11 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
12 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
13 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
14 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
15 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -5, -5, -5, -5, -5};
18 extern void abort (void);
20 void __attribute__((noinline)) foo (int *a, int len)
22 int i;
23 for (i = 0; i < len; i++)
25 a[i] = 0;
26 a[i + 5] = -5;
30 void check (int *a, int *res, int len)
32 int i;
34 for (i = 0; i < len; i++)
35 if (a[i] != res[i])
36 abort ();
39 int main (void)
41 foo (arr, 0);
42 check (arr, result0, 10);
44 foo (arr, 1);
45 check (arr, result1, 10);
47 foo (arr, 2);
48 check (arr, result2, 10);
50 foo (arr, 3);
51 check (arr, result3, 10);
53 foo (arr, 4);
54 check (arr, result4, 10);
56 foo (arr, 100);
57 check (arr, result100, 105);
59 return 0;