Debian Codegraph @

gcc/testsuite/g++.target/aarch64/sve/catch_3.C

raw
1 /* { dg-do run { target aarch64_sve_hw } } */
2 /* { dg-options "-O3 -fopenmp-simd -fno-omit-frame-pointer" } */
3
4 /* Invoke X (P##n) for n in [0, 7]. */
5 #define REPEAT8(X, P) \
6 X (P##0) X (P##1) X (P##2) X (P##3) X (P##4) X (P##5) X (P##6) X (P##7)
7
8 /* Invoke X (n) for all octal n in [0, 39]. */
9 #define REPEAT40(X) \
10 REPEAT8 (X, 0) REPEAT8 (X, 1) REPEAT8 (X, 2) REPEAT8 (X, 3) REPEAT8 (X, 4)
11
12 volatile int testi, sink;
13
14 /* Take 2 stack arguments and throw to f3. */
15 void __attribute__ ((weak))
16 f1 (int x[40][100], int *y, int z1, int z2, int z3, int z4,
17 int z5, int z6, int z7, int z8)
18 {
19 /* A wild write to x and y. */
20 sink = z1;
21 sink = z2;
22 sink = z3;
23 sink = z4;
24 sink = z5;
25 sink = z6;
26 sink = z7;
27 sink = z8;
28 asm volatile ("" ::: "memory");
29 if (y[testi] == x[testi][testi])
30 throw 100;
31 }
32
33 /* Expect vector work to be done, with spilling of vector registers. */
34 void __attribute__ ((weak))
35 f2 (int x[40][100], int *y)
36 {
37 /* Try to force some spilling. */
38 #define DECLARE(N) int y##N = y[N];
39 REPEAT40 (DECLARE);
40 for (int j = 0; j < 20; ++j)
41 {
42 f1 (x, y, 1, 2, 3, 4, 5, 6, 7, 8);
43 #pragma omp simd
44 for (int i = 0; i < 100; ++i)
45 {
46 #define INC(N) x[N][i] += y##N;
47 REPEAT40 (INC);
48 }
49 }
50 }
51
52 /* Catch an exception thrown from f1, via f2. */
53 void __attribute__ ((weak))
54 f3 (int x[40][100], int *y, int *z)
55 {
56 volatile int extra = 111;
57 try
58 {
59 f2 (x, y);
60 }
61 catch (int val)
62 {
63 *z = val + extra;
64 }
65 }
66
67 static int x[40][100];
68 static int y[40];
69 static int z;
70
71 int
72 main (void)
73 {
74 f3 (x, y, &z);
75 if (z != 211)
76 __builtin_abort ();
77 return 0;
78 }