1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-lim2-details" } */
3 
4 int x;
5 int a[100];
6 
7 struct a
8 {
9   int X;
10   int Y;
11 };
12 
13 /* Word size is long long for 64-bit mingw target.  */
14 #ifdef _WIN64
15 #define LONG long long
16 #else
17 #define LONG long
18 #endif
19 
20 struct a arr[100];
21 
test1(int b)22 void test1(int b)
23 {
24   unsigned i;
25 
26   /* And here.  */
27   for (i = 0; i < 100; i++)
28     {
29       arr[b+8].X += i;
30       arr[b+9].X += i;
31     }
32 }
33 
test2(struct a * A,int b)34 void test2(struct a *A, int b)
35 {
36   unsigned i;
37 
38   /* And here as well.  */
39   for (i = 0; i < 100; i++)
40     {
41       A[b].X += i;
42       A[b+1].Y += i;
43     }
44 }
45 
test3(unsigned LONG b)46 void test3(unsigned LONG b)
47 {
48   unsigned i;
49 
50   /* And here.  */
51   for (i = 0; i < 100; i++)
52     {
53       arr[b+8].X += i;
54       arr[b+9].X += i;
55     }
56 }
57 
test4(struct a * A,unsigned LONG b)58 void test4(struct a *A, unsigned LONG b)
59 {
60   unsigned i;
61 
62   /* And here as well.  */
63   for (i = 0; i < 100; i++)
64     {
65       A[b].X += i;
66       A[b+1].Y += i;
67     }
68 }
69 /* long index not hoisted for avr target PR 36561 */
70 /* { dg-final { scan-tree-dump-times "Executing store motion of" 8 "lim2" { xfail { "avr-*-*" } } } } */
71 /* { dg-final { scan-tree-dump-times "Executing store motion of" 6 "lim2" { target { "avr-*-*" } } } } */
72