]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-5.c
Fix profile update in tree_transform_and_unroll_loop
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / predcom-dse-5.c
1 /* { dg-do run } */
2 /* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details-blocks" } */
3
4 int arr[105] = {2, 3, 5, 7, 11};
5 int result0[10] = {2, 3, 5, 7, 11};
6 int result1[10] = {0, -1, -2, -3, 11, 0};
7 int result2[10] = {0, 0, -1, -2, -3, 0};
8 int result3[10] = {0, 0, 0, -1, -2, -3, 0};
9 int result4[10] = {0, 0, 0, 0, -1, -2, -3, 0};
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, -1, -2, -3, 0};
17
18 extern void abort (void);
19
20 void __attribute__((noinline)) foo (int *a, int len)
21 {
22 int i;
23 for (i = 0; i < len; i++)
24 {
25 a[i] = 0;
26 a[i + 1] = -1;
27 a[i + 2] = -2;
28 a[i + 3] = -3;
29 }
30 }
31
32 void check (int *a, int *res, int len)
33 {
34 int i;
35
36 for (i = 0; i < len; i++)
37 if (a[i] != res[i])
38 abort ();
39 }
40
41 int main (void)
42 {
43 foo (arr, 0);
44 check (arr, result0, 10);
45
46 foo (arr, 1);
47 check (arr, result1, 10);
48
49 foo (arr, 2);
50 check (arr, result2, 10);
51
52 foo (arr, 3);
53 check (arr, result3, 10);
54
55 foo (arr, 4);
56 check (arr, result4, 10);
57
58 foo (arr, 100);
59 check (arr, result100, 105);
60
61 return 0;
62 }
63 /* { dg-final { scan-tree-dump "Store-stores chain" "pcom"} } */
64 /* { dg-final { scan-tree-dump-not "Invalid sum" "pcom" } } */