1 /* PR target/93141 */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -masm=att" } */
4 /* { dg-final { scan-assembler-not "cmp\[lq]\t" } } */
5 /* { dg-final { scan-assembler-times "setc\t%" 5 } } */
6 /* { dg-final { scan-assembler-times "seto\t%" 7 } } */
7 /* { dg-final { scan-assembler-times "adc\[lq]\t" 9 } } */
8 
9 #ifdef __x86_64__
10 typedef unsigned __int128 U;
11 typedef unsigned long long HU;
12 typedef signed __int128 S;
13 #else
14 typedef unsigned long long U;
15 typedef unsigned int HU;
16 typedef signed long long S;
17 #endif
18 int o;
19 
20 U
foo(U x,U y)21 foo (U x, U y)
22 {
23   U z;
24   o = __builtin_add_overflow (x, y, &z);
25   return z;
26 }
27 
28 U
bar(U x)29 bar (U x)
30 {
31   U z;
32   o = __builtin_add_overflow (x, ((U) 0xdeadbee) << (sizeof (U) * __CHAR_BIT__ / 2), &z);
33   return z;
34 }
35 
36 U
baz(U x)37 baz (U x)
38 {
39   U z;
40   o = __builtin_add_overflow (x, (((U) 0xdeadbee) << (sizeof (U) * __CHAR_BIT__ / 2))
41 				 | (U) 0xbeedead, &z);
42   return z;
43 }
44 
45 S
qux(S x,S y)46 qux (S x, S y)
47 {
48   S z;
49   o = __builtin_add_overflow (x, y, &z);
50   return z;
51 }
52 
53 S
quux(S x)54 quux (S x)
55 {
56   S z;
57   o = __builtin_add_overflow (x, ((S) 0xdeadbee) << (sizeof (S) * __CHAR_BIT__ / 2), &z);
58   return z;
59 }
60 
61 S
corge(S x)62 corge (S x)
63 {
64   S z;
65   o = __builtin_add_overflow (x, (((S) 0xdeadbee) << (sizeof (S) * __CHAR_BIT__ / 2))
66 				 | (S) 0xbeedead, &z);
67   return z;
68 }
69 
70 S
grault(S x)71 grault (S x)
72 {
73   S z;
74   o = __builtin_add_overflow (x, -((S) 0xdeadbee) << (sizeof (S) * __CHAR_BIT__ / 2), &z);
75   return z;
76 }
77 
78 S
garply(S x)79 garply (S x)
80 {
81   S z;
82   o = __builtin_add_overflow (x, (-(((S) 0xdeadbee) << (sizeof (S) * __CHAR_BIT__ / 2)))
83 				 | (S) 0xbeedead, &z);
84   return z;
85 }
86 
87 S
waldo(S x)88 waldo (S x)
89 {
90   S z;
91   o = __builtin_add_overflow (x, (S) ((((S) 0xdeadbee) << (sizeof (S) * __CHAR_BIT__ / 2))
92 				      | -(HU) 0xbeedead), &z);
93   return z;
94 }
95 
96 S
fred(S x)97 fred (S x)
98 {
99   S z;
100   o = __builtin_add_overflow (x, (S) ((-(((S) 0xdeadbee) << (sizeof (S) * __CHAR_BIT__ / 2)))
101 				      | -(HU) 0xbeedead), &z);
102   return z;
103 }
104 
105 U
plugh(U x)106 plugh (U x)
107 {
108   U z;
109   o = __builtin_add_overflow (x, (U) ((((U) 0xdeadbee) << (sizeof (U) * __CHAR_BIT__ / 2))
110 				      | -(HU) 0xbeedead), &z);
111   return z;
112 }
113 
114 U
xyzzy(U x)115 xyzzy (U x)
116 {
117   U z;
118   o = __builtin_add_overflow (x, (U) ((-(((U) 0xdeadbee) << (sizeof (U) * __CHAR_BIT__ / 2)))
119 				      | -(HU) 0xbeedead), &z);
120   return z;
121 }
122