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-not "adc\[lq]\t" } } */
6 /* { dg-final { scan-assembler-times "seto\t%" 7 } } */
7 /* { dg-final { scan-assembler-times "sbb\[lq]\t" 5 } } */
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 signed int HU;
16 typedef signed long long S;
17 #endif
18 int o;
19
20 S
qux(S x,S y)21 qux (S x, S y)
22 {
23 S z;
24 o = __builtin_sub_overflow (x, y, &z);
25 return z;
26 }
27
28 S
quux(S x)29 quux (S x)
30 {
31 S z;
32 o = __builtin_sub_overflow (x, ((S) 0xdeadbee) << (sizeof (S) * __CHAR_BIT__ / 2), &z);
33 return z;
34 }
35
36 S
corge(S x)37 corge (S x)
38 {
39 S z;
40 o = __builtin_sub_overflow (x, (((S) 0xdeadbee) << (sizeof (S) * __CHAR_BIT__ / 2))
41 | (S) 0xbeedead, &z);
42 return z;
43 }
44
45 S
grault(S x)46 grault (S x)
47 {
48 S z;
49 o = __builtin_sub_overflow (x, -((S) 0xdeadbee) << (sizeof (S) * __CHAR_BIT__ / 2), &z);
50 return z;
51 }
52
53 S
garply(S x)54 garply (S x)
55 {
56 S z;
57 o = __builtin_sub_overflow (x, (-(((S) 0xdeadbee) << (sizeof (S) * __CHAR_BIT__ / 2)))
58 | (S) 0xbeedead, &z);
59 return z;
60 }
61
62 S
waldo(S x)63 waldo (S x)
64 {
65 S z;
66 o = __builtin_sub_overflow (x, (S) ((((S) 0xdeadbee) << (sizeof (S) * __CHAR_BIT__ / 2))
67 | -(HU) 0xbeedead), &z);
68 return z;
69 }
70
71 S
fred(S x)72 fred (S x)
73 {
74 S z;
75 o = __builtin_sub_overflow (x, (S) ((-(((S) 0xdeadbee) << (sizeof (S) * __CHAR_BIT__ / 2)))
76 | -(HU) 0xbeedead), &z);
77 return z;
78 }
79