PR tree-optimization/85826 - ICE in gimple-ssa-warn-restruct on
[official-gcc.git] / gcc / testsuite / gcc.dg / pr67089-3.c
blob22576e56cbf11278ab80ef282dcc3cc26dcf5d95
1 /* PR target/67089 */
2 /* { dg-do run } */
3 /* { dg-options "-O2" } */
5 extern void abort (void);
7 int cnt, d;
9 __attribute__((noinline, noclone))
10 void foo (int x)
12 asm volatile ("" : "+m" (d) : "g" (x) : "memory");
13 cnt++;
16 #define T(n, type, op, cond) \
17 __attribute__((noinline, noclone)) \
18 type \
19 f##n (type x, type y) \
20 { \
21 type r = op; \
22 cond; \
23 return r; \
26 T (1, unsigned int, x + y, if (r > x) foo (0))
27 T (2, unsigned long, x + y, if (r <= x) foo (0))
28 T (3, unsigned short, x + y, if (x < r) foo (r))
29 T (4, unsigned long long, x + y, if (x >= r) foo (0))
30 T (5, unsigned int, x + y, if (r >= x) foo (0))
31 T (6, unsigned long, x + y, if (r < x) foo (0))
32 T (7, unsigned short, x + y, if (x <= r) foo (r))
33 T (8, unsigned long long, x + y, if (d || x > r) foo (0))
34 T (9, unsigned int, x + y, if (d || r > x) foo (0))
35 T (10, unsigned long, x + y, if (d || r <= x) foo (0))
36 T (11, unsigned char, x + y, if (d || x < r) foo (0))
37 T (12, unsigned long long, x + y, if (d || x >= r) foo (0))
38 T (13, unsigned int, x + y, if (d || r >= x) foo (0))
39 T (14, unsigned long, x + y, if (d || r < x) foo (0))
40 T (15, unsigned short, x + y, if (d || x <= r) foo (0))
41 T (16, unsigned long long, x + y, if (d || x > r) foo (0))
43 int
44 main ()
46 if (f1 (-7U, 0) != -7U || cnt != 0) abort ();
47 if (f1 (-7U, 6) != -1U || cnt != 1) abort ();
48 if (f1 (-7U, 7) != 0U || cnt != 1) abort ();
49 if (f1 (-7U, 8) != 1U || cnt != 1) abort ();
50 if (f2 (-9UL, 0) != -9UL || cnt != 2) abort ();
51 if (f2 (-9UL, 8) != -1UL || cnt != 2) abort ();
52 if (f2 (-9UL, 9) != 0UL || cnt != 3) abort ();
53 if (f2 (-9UL, 10) != 1UL || cnt != 4) abort ();
54 if (f3 (-15, 0) != (unsigned short) -15 || cnt != 4) abort ();
55 if (f3 (-15, 14) != (unsigned short) -1 || cnt != 5) abort ();
56 if (f3 (-15, 15) != 0 || cnt != 5) abort ();
57 if (f3 (-15, 16) != 1 || cnt != 5) abort ();
58 if (f4 (-9132ULL, 0) != -9132ULL || cnt != 6) abort ();
59 if (f4 (-9132ULL, 9131) != -1ULL || cnt != 6) abort ();
60 if (f4 (-9132ULL, 9132) != 0 || cnt != 7) abort ();
61 if (f4 (-9132ULL, 9133) != 1ULL || cnt != 8) abort ();
62 if (f5 (-7U, 0) != -7U || cnt != 9) abort ();
63 if (f5 (-7U, 6) != -1U || cnt != 10) abort ();
64 if (f5 (-7U, 7) != 0U || cnt != 10) abort ();
65 if (f5 (-7U, 8) != 1U || cnt != 10) abort ();
66 if (f6 (-9UL, 0) != -9UL || cnt != 10) abort ();
67 if (f6 (-9UL, 8) != -1UL || cnt != 10) abort ();
68 if (f6 (-9UL, 9) != 0UL || cnt != 11) abort ();
69 if (f6 (-9UL, 10) != 1UL || cnt != 12) abort ();
70 if (f7 (-15, 0) != (unsigned short) -15 || cnt != 13) abort ();
71 if (f7 (-15, 14) != (unsigned short) -1 || cnt != 14) abort ();
72 if (f7 (-15, 15) != 0 || cnt != 14) abort ();
73 if (f7 (-15, 16) != 1 || cnt != 14) abort ();
74 if (f8 (-9132ULL, 0) != -9132ULL || cnt != 14) abort ();
75 if (f8 (-9132ULL, 9131) != -1ULL || cnt != 14) abort ();
76 if (f8 (-9132ULL, 9132) != 0 || cnt != 15) abort ();
77 if (f8 (-9132ULL, 9133) != 1ULL || cnt != 16) abort ();
78 cnt = 0;
79 if (f9 (-7U, 0) != -7U || cnt != 0) abort ();
80 if (f9 (-7U, 6) != -1U || cnt != 1) abort ();
81 if (f9 (-7U, 7) != 0U || cnt != 1) abort ();
82 if (f9 (-7U, 8) != 1U || cnt != 1) abort ();
83 if (f10 (-9UL, 0) != -9UL || cnt != 2) abort ();
84 if (f10 (-9UL, 8) != -1UL || cnt != 2) abort ();
85 if (f10 (-9UL, 9) != 0UL || cnt != 3) abort ();
86 if (f10 (-9UL, 10) != 1UL || cnt != 4) abort ();
87 if (f11 (-15, 0) != (unsigned char) -15 || cnt != 4) abort ();
88 if (f11 (-15, 14) != (unsigned char) -1 || cnt != 5) abort ();
89 if (f11 (-15, 15) != 0 || cnt != 5) abort ();
90 if (f11 (-15, 16) != 1 || cnt != 5) abort ();
91 if (f12 (-9132ULL, 0) != -9132ULL || cnt != 6) abort ();
92 if (f12 (-9132ULL, 9131) != -1ULL || cnt != 6) abort ();
93 if (f12 (-9132ULL, 9132) != 0 || cnt != 7) abort ();
94 if (f12 (-9132ULL, 9133) != 1ULL || cnt != 8) abort ();
95 if (f13 (-7U, 0) != -7U || cnt != 9) abort ();
96 if (f13 (-7U, 6) != -1U || cnt != 10) abort ();
97 if (f13 (-7U, 7) != 0U || cnt != 10) abort ();
98 if (f13 (-7U, 8) != 1U || cnt != 10) abort ();
99 if (f14 (-9UL, 0) != -9UL || cnt != 10) abort ();
100 if (f14 (-9UL, 8) != -1UL || cnt != 10) abort ();
101 if (f14 (-9UL, 9) != 0UL || cnt != 11) abort ();
102 if (f14 (-9UL, 10) != 1UL || cnt != 12) abort ();
103 if (f15 (-15, 0) != (unsigned short) -15 || cnt != 13) abort ();
104 if (f15 (-15, 14) != (unsigned short) -1 || cnt != 14) abort ();
105 if (f15 (-15, 15) != 0 || cnt != 14) abort ();
106 if (f15 (-15, 16) != 1 || cnt != 14) abort ();
107 if (f16 (-9132ULL, 0) != -9132ULL || cnt != 14) abort ();
108 if (f16 (-9132ULL, 9131) != -1ULL || cnt != 14) abort ();
109 if (f16 (-9132ULL, 9132) != 0 || cnt != 15) abort ();
110 if (f16 (-9132ULL, 9133) != 1ULL || cnt != 16) abort ();
111 return 0;