libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / sra-longjmp-1.c
blobfa19e7681305082ee3bae46f6f729e5314f5b262
1 /* { dg-do run } */
2 /* { dg-options "-O2 -fdump-tree-sra" } */
3 /* { dg-require-effective-target indirect_jumps } */
5 #include <setjmp.h>
7 struct S {
8 long *b;
9 int c;
10 int s;
13 static jmp_buf the_jmpbuf;
14 volatile short vs = 0;
15 long buf[16];
16 long * volatile pbuf = (long *) &buf;
18 static void __attribute__((noinline))
19 crazy_alloc_s (struct S *p)
21 int s = p->c ? p->c * 2 : 16;
23 long *b = pbuf;
24 if (!b || s > 16)
26 p->s = -p->s;
27 vs = 127;
28 longjmp (the_jmpbuf, 1);
31 __builtin_memcpy (b, p->b, p->c);
32 p->b = b;
33 p->s = s;
34 pbuf = 0;
35 return;
38 long __attribute__((noipa))
39 process (long v)
41 return v + 1;
44 void
45 foo (void)
47 struct S stack;
49 if (setjmp (the_jmpbuf))
50 return;
52 stack.c = 0;
53 crazy_alloc_s (&stack);
54 stack.b[0] = 1;
55 stack.c = 1;
57 while (stack.c)
59 long l = stack.b[--stack.c];
61 if (l > 0)
63 for (int i = 0; i < 4; i++)
65 if (stack.s <= stack.c + 1)
66 crazy_alloc_s (&stack);
67 l = process (l);
68 stack.b[stack.c++] = l;
73 return;
76 int main (int argc, char **argv)
78 vs = 0;
79 pbuf = (long *) &buf;
80 foo ();
81 if (vs != 127)
82 __builtin_abort ();
84 return 0;
87 /* { dg-final { scan-tree-dump-not "Created a replacement for stack offset" "sra"} } */