1 /* { dg-do compile } */
2 /* { dg-options "-O3 -fgimple -fdump-tree-cunroll-blocks-details" } */
3 
4 #if __SIZEOF_INT__ < 4
5 __extension__ typedef __INT32_TYPE__ i32;
6 #else
7 typedef int i32;
8 #endif
9 
10 struct a {i32 a[8];i32 b;};
11 
12 void __GIMPLE (ssa,startwith("fix_loops"))
t(struct a * a)13 t (struct a * a)
14 {
15   i32 i;
16   i32 _1;
17   i32 _2;
18   i32 _9;
19   i32 _11;
20 
21 __BB(2):
22   _11 = a_6(D)->a[0];
23   if (_11 != _Literal (i32) 0)
24     goto __BB6;
25   else
26     goto __BB3;
27 
28 __BB(3):
29   return;
30 
31 __BB(4):
32   _1 = _2 + _Literal (i32) 1;
33   a_6(D)->a[i_19] = _1;
34   i_8 = i_19 + _Literal (i32) 1;
35   if (i_8 <= _Literal (i32) 123455)
36     goto __BB5;
37   else
38     goto __BB3;
39 
40 __BB(5):
41   i_19 = __PHI (__BB6: _Literal (i32) 1, __BB4: i_8);
42   _2 = a_6(D)->a[i_19];
43   if (_2 != _Literal (i32) 0)
44     goto __BB4;
45   else
46     goto __BB3;
47 
48 __BB(6):
49   _9 = _11 + _Literal (i32) 1;
50   a_6(D)->a[0] = _9;
51   goto __BB5;
52 }
53 
54 /* This testcase relies on the fact that we do not eliminate the redundant test
55    for i early.  It is necessary to disable all passes that do so, for the
56    moment starting with the loop pipeline is good enough.  */
57 /* { dg-final { scan-tree-dump-times "Loop 1 iterates 123454 times" 1 "cunroll" } } */
58 /* { dg-final { scan-tree-dump-times "Last iteration exit edge was proved true" 1 "cunroll" } } */
59 /* { dg-final { scan-tree-dump-times "Exit condition of peeled iterations was eliminated" 1 "cunroll" } } */
60 /* { dg-final { scan-tree-dump-times "loop with 6 iterations completely unrolled" 1 "cunroll" } } */
61 /* { dg-final { scan-tree-dump-not "Invalid sum" "cunroll" } } */
62