PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / pr78468.c
bloba882d9a7deea8943d8babaa00259b048e96a508a
1 /* { dg-do run } */
2 /* { dg-require-effective-target alloca } */
3 /* { dg-options "-O2 -fno-inline" } */
5 /* Test that targets correctly round the size of the outgoing arguments
6 to a multiple of STACK_BOUNDARY. There is a serious alignment bug if
7 aligned alloca does not get aligned! */
9 __extension__ typedef __UINTPTR_TYPE__ uintptr_t;
10 extern void abort (void);
12 volatile int xx;
13 volatile int x = 16;
15 void
16 t1 (int x0, int x1, int x2, int x3, int x4, int x5, int x6, int x7,
17 void *p, int align)
19 xx = x0 + x1 + x2 + x3 + x4 + x4 + x6 + x7;
20 if ((int)(uintptr_t)p & (align-1))
21 abort ();
24 void
25 t2 (int x0, int x1, int x2, int x3, int x4, int x5, int x6, int x7,
26 void *p, int align, int dummy)
28 xx = x0 + x1 + x2 + x3 + x4 + x4 + x6 + x7;
29 if ((int)(uintptr_t)p & (align-1))
30 abort ();
33 void
34 t1_a4 (int size)
36 void *p = __builtin_alloca_with_align (size, 32);
37 t1 (0, 0, 0, 0, 0, 0, 0, 0, p, 4);
40 void
41 t2_a4 (int size)
43 void *p = __builtin_alloca_with_align (size, 32);
44 t2 (0, 0, 0, 0, 0, 0, 0, 0, p, 4, 0);
47 void
48 t1_a8 (int size)
50 void *p = __builtin_alloca_with_align (size, 64);
51 t1 (0, 0, 0, 0, 0, 0, 0, 0, p, 8);
54 void
55 t2_a8 (int size)
57 void *p = __builtin_alloca_with_align (size, 64);
58 t2 (0, 0, 0, 0, 0, 0, 0, 0, p, 8, 0);
61 void
62 t1_a16 (int size)
64 void *p = __builtin_alloca_with_align (size, 128);
65 t1 (0, 0, 0, 0, 0, 0, 0, 0, p, 16);
68 void
69 t2_a16 (int size)
71 void *p = __builtin_alloca_with_align (size, 128);
72 t2 (0, 0, 0, 0, 0, 0, 0, 0, p, 16, 0);
75 void
76 t1_a32 (int size)
78 void *p = __builtin_alloca_with_align (size, 256);
79 t1 (0, 0, 0, 0, 0, 0, 0, 0, p, 32);
82 void
83 t2_a32 (int size)
85 void *p = __builtin_alloca_with_align (size, 256);
86 t2 (0, 0, 0, 0, 0, 0, 0, 0, p, 32, 0);
90 int
91 main ()
93 t1_a4 (x);
94 t2_a4 (x);
95 t1_a8 (x);
96 t2_a8 (x);
97 t1_a16 (x);
98 t2_a16 (x);
99 t1_a32 (x);
100 t2_a32 (x);
101 return 0;