1 /* { dg-require-stack-size "0x80100" } */
2 
3 /* Like pr28982a.c, but with the spill slots outside the range of
4    a single sp-based load on ARM.  This test tests for cases where
5    the addresses in the base and index reloads require further reloads.  */
6 #define NITER 4
7 #define NVARS 20
8 #define MULTI(X) \
9   X( 0), X( 1), X( 2), X( 3), X( 4), X( 5), X( 6), X( 7), X( 8), X( 9), \
10   X(10), X(11), X(12), X(13), X(14), X(15), X(16), X(17), X(18), X(19)
11 
12 #define DECLAREI(INDEX) inc##INDEX = incs[INDEX]
13 #define DECLAREF(INDEX) *ptr##INDEX = ptrs[INDEX], result##INDEX = 0
14 #define LOOP(INDEX) result##INDEX += *ptr##INDEX, ptr##INDEX += inc##INDEX
15 #define COPYOUT(INDEX) results[INDEX] = result##INDEX
16 
17 float *ptrs[NVARS];
18 float results[NVARS];
19 int incs[NVARS];
20 
21 struct big { int i[0x10000]; };
22 void __attribute__((noinline))
bar(struct big b)23 bar (struct big b)
24 {
25   incs[0] += b.i[0];
26 }
27 
28 void __attribute__((noinline))
foo(int n)29 foo (int n)
30 {
31   struct big b = {};
32   int MULTI (DECLAREI);
33   float MULTI (DECLAREF);
34   while (n--)
35     MULTI (LOOP);
36   MULTI (COPYOUT);
37   bar (b);
38 }
39 
40 float input[NITER * NVARS];
41 
42 int
main(void)43 main (void)
44 {
45   int i;
46 
47   for (i = 0; i < NVARS; i++)
48     ptrs[i] = input + i, incs[i] = i;
49   for (i = 0; i < NITER * NVARS; i++)
50     input[i] = i;
51   foo (NITER);
52   for (i = 0; i < NVARS; i++)
53     if (results[i] != i * NITER * (NITER + 1) / 2)
54       return 1;
55   return 0;
56 }
57