111
|
1 /* PR target/67089 */
|
|
2 /* { dg-do run } */
|
|
3 /* { dg-options "-O2" } */
|
|
4
|
|
5 extern void abort (void);
|
|
6
|
|
7 int cnt, d;
|
|
8
|
|
9 __attribute__((noinline, noclone))
|
|
10 void foo (int x)
|
|
11 {
|
|
12 asm volatile ("" : "+m" (d) : "g" (x) : "memory");
|
|
13 cnt++;
|
|
14 }
|
|
15
|
|
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; \
|
|
24 }
|
|
25
|
|
26 T (1, unsigned int, x - y, if (r > y) foo (0))
|
|
27 T (2, unsigned long, x - y, if (r <= y) foo (0))
|
|
28 T (3, unsigned short, x - y, if (y < r) foo (r))
|
|
29 T (4, unsigned long long, x - y, if (y >= r) foo (0))
|
|
30 T (5, unsigned int, x - y, if (r >= y) foo (0))
|
|
31 T (6, unsigned long, x - y, if (r < y) foo (0))
|
|
32 T (7, unsigned short, x - y, if (y <= r) foo (r))
|
|
33 T (8, unsigned long long, x - y, if (d || y > r) foo (0))
|
|
34 T (9, unsigned int, x - y, if (d || r > y) foo (0))
|
|
35 T (10, unsigned long, x - y, if (d || r <= y) foo (0))
|
|
36 T (11, unsigned char, x - y, if (d || y < r) foo (0))
|
|
37 T (12, unsigned long long, x - y, if (d || y >= r) foo (0))
|
|
38 T (13, unsigned int, x - y, if (d || r >= y) foo (0))
|
|
39 T (14, unsigned long, x - y, if (d || r < y) foo (0))
|
|
40 T (15, unsigned short, x - y, if (d || y <= r) foo (0))
|
|
41 T (16, unsigned long long, x - y, if (d || y > r) foo (0))
|
|
42
|
|
43 int
|
|
44 main ()
|
|
45 {
|
|
46 if (f1 (5, 3) != 2U || cnt != 0) abort ();
|
|
47 if (f1 (5, 7) != -2U || cnt != 1) abort ();
|
|
48 if (f1 (5, 5) != 0U || cnt != 1) abort ();
|
|
49 if (f1 (5, 0) != 5U || cnt != 2) abort ();
|
|
50 if (f2 (7, 1) != 6UL || cnt != 2) abort ();
|
|
51 if (f2 (7, 8) != -1UL || cnt != 2) abort ();
|
|
52 if (f2 (9, 9) != 0UL || cnt != 3) abort ();
|
|
53 if (f2 (9, 0) != 9UL || cnt != 3) abort ();
|
|
54 if (f3 (15, 14) != 1 || cnt != 3) abort ();
|
|
55 if (f3 (15, 25) != (unsigned short) -10 || cnt != 4) abort ();
|
|
56 if (f3 (15, 15) != 0 || cnt != 4) abort ();
|
|
57 if (f3 (15, 0) != 15 || cnt != 5) abort ();
|
|
58 if (f4 (9132, 9127) != 5ULL || cnt != 6) abort ();
|
|
59 if (f4 (9132, 9137) != -5ULL || cnt != 6) abort ();
|
|
60 if (f4 (9132, 9132) != 0 || cnt != 7) abort ();
|
|
61 if (f4 (9132, 0) != 9132ULL || cnt != 7) abort ();
|
|
62 if (f5 (5, 3) != 2U || cnt != 7) abort ();
|
|
63 if (f5 (5, 7) != -2U || cnt != 8) abort ();
|
|
64 if (f5 (5, 5) != 0U || cnt != 8) abort ();
|
|
65 if (f5 (5, 0) != 5U || cnt != 9) abort ();
|
|
66 if (f6 (7, 1) != 6UL || cnt != 9) abort ();
|
|
67 if (f6 (7, 8) != -1UL || cnt != 9) abort ();
|
|
68 if (f6 (9, 9) != 0UL || cnt != 10) abort ();
|
|
69 if (f6 (9, 0) != 9UL || cnt != 10) abort ();
|
|
70 if (f7 (15, 14) != 1 || cnt != 10) abort ();
|
|
71 if (f7 (15, 25) != (unsigned short) -10 || cnt != 11) abort ();
|
|
72 if (f7 (15, 15) != 0 || cnt != 11) abort ();
|
|
73 if (f7 (15, 0) != 15 || cnt != 12) abort ();
|
|
74 if (f8 (9132, 9127) != 5ULL || cnt != 13) abort ();
|
|
75 if (f8 (9132, 9137) != -5ULL || cnt != 13) abort ();
|
|
76 if (f8 (9132, 9132) != 0 || cnt != 14) abort ();
|
|
77 if (f8 (9132, 0) != 9132ULL || cnt != 14) abort ();
|
|
78 cnt = 0;
|
|
79 if (f9 (5, 3) != 2U || cnt != 0) abort ();
|
|
80 if (f9 (5, 7) != -2U || cnt != 1) abort ();
|
|
81 if (f9 (5, 5) != 0U || cnt != 1) abort ();
|
|
82 if (f9 (5, 0) != 5U || cnt != 2) abort ();
|
|
83 if (f10 (7, 1) != 6UL || cnt != 2) abort ();
|
|
84 if (f10 (7, 8) != -1UL || cnt != 2) abort ();
|
|
85 if (f10 (9, 9) != 0UL || cnt != 3) abort ();
|
|
86 if (f10 (9, 0) != 9UL || cnt != 3) abort ();
|
|
87 if (f11 (15, 14) != 1 || cnt != 3) abort ();
|
|
88 if (f11 (15, 25) != (unsigned char) -10 || cnt != 4) abort ();
|
|
89 if (f11 (15, 15) != 0 || cnt != 4) abort ();
|
|
90 if (f11 (15, 0) != 15 || cnt != 5) abort ();
|
|
91 if (f12 (9132, 9127) != 5ULL || cnt != 6) abort ();
|
|
92 if (f12 (9132, 9137) != -5ULL || cnt != 6) abort ();
|
|
93 if (f12 (9132, 9132) != 0 || cnt != 7) abort ();
|
|
94 if (f12 (9132, 0) != 9132ULL || cnt != 7) abort ();
|
|
95 if (f13 (5, 3) != 2U || cnt != 7) abort ();
|
|
96 if (f13 (5, 7) != -2U || cnt != 8) abort ();
|
|
97 if (f13 (5, 5) != 0U || cnt != 8) abort ();
|
|
98 if (f13 (5, 0) != 5U || cnt != 9) abort ();
|
|
99 if (f14 (7, 1) != 6UL || cnt != 9) abort ();
|
|
100 if (f14 (7, 8) != -1UL || cnt != 9) abort ();
|
|
101 if (f14 (9, 9) != 0UL || cnt != 10) abort ();
|
|
102 if (f14 (9, 0) != 9UL || cnt != 10) abort ();
|
|
103 if (f15 (15, 14) != 1 || cnt != 10) abort ();
|
|
104 if (f15 (15, 25) != (unsigned short) -10 || cnt != 11) abort ();
|
|
105 if (f15 (15, 15) != 0 || cnt != 11) abort ();
|
|
106 if (f15 (15, 0) != 15 || cnt != 12) abort ();
|
|
107 if (f16 (9132, 9127) != 5ULL || cnt != 13) abort ();
|
|
108 if (f16 (9132, 9137) != -5ULL || cnt != 13) abort ();
|
|
109 if (f16 (9132, 9132) != 0 || cnt != 14) abort ();
|
|
110 if (f16 (9132, 0) != 9132ULL || cnt != 14) abort ();
|
|
111 return 0;
|
|
112 }
|