testsuite: Fix tail_call and musttail effective targets [PR116080]
[official-gcc.git] / gcc / testsuite / gcc.dg / pr97459-5.c
blobf658a5a8968b6247569614165a597911fb9e7008
1 /* PR rtl-optimization/97459 */
2 /* { dg-do run } */
3 /* { dg-options "-O2" } */
4 /* { dg-additional-options "-DEXPENSIVE" { target run_expensive_tests } } */
6 #ifdef __SIZEOF_INT128__
7 typedef __uint128_t T;
8 #else
9 typedef unsigned long long T;
10 #endif
12 T __attribute__((noipa)) foo (T x, T n, T *r) { *r = x % n; return x / n; }
13 #define C(n) T __attribute__((noipa)) foo##n (T x, T *r) { *r = x % (n - 10000); return x / (n - 10000); }
15 #define C1(n) C(n##1) C(n##3) C(n##5) C(n##7) C(n##9)
16 #define C2(n) C1(n##0) C1(n##1) C1(n##2) C1(n##3) C1(n##4) \
17 C1(n##5) C1(n##6) C1(n##7) C1(n##8) C1(n##9)
18 #ifdef EXPENSIVE
19 #define C3(n) C2(n##0) C2(n##1) C2(n##2) C2(n##3) C2(n##4) \
20 C2(n##5) C2(n##6) C2(n##7) C2(n##8) C2(n##9)
21 #define C4(n) C3(n##0) C3(n##1) C3(n##2) C3(n##3) C3(n##4) \
22 C3(n##5) C3(n##6) C3(n##7) C3(n##8) C3(n##9)
23 #else
24 #define C3(n) C2(n##0) C2(n##4) C2(n##9)
25 #define C4(n) C3(n##0) C3(n##3) C3(n##7)
26 #endif
27 #define TESTS C4(1) C1(10010) C1(10012) C1(16144)
29 TESTS
31 struct S { T x; T (*foo) (T, T *); };
33 #undef C
34 #define C(n) { n - 10000, foo##n },
36 struct S tests[] = {
37 TESTS
38 { 0, 0 }
41 int
42 main ()
44 int i, j, k;
45 for (k = 0; tests[k].x; k++)
46 for (i = 0; i < sizeof (T) * __CHAR_BIT__; i++)
47 for (j = -5; j <= 5; j++)
49 T x = ((T) 1 << i) + j;
50 T r1, r2;
51 if (foo (x, tests[k].x, &r1) != tests[k].foo (x, &r2)
52 || r1 != r2)
53 __builtin_abort ();
55 return 0;