1 /* PR target/91635 */
2 
3 #if __CHAR_BIT__ == 8 && __SIZEOF_SHORT__ == 2 \
4     && __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8
5 unsigned short b, c;
6 int u, v, w, x;
7 
8 __attribute__ ((noipa)) int
foo(unsigned short c)9 foo (unsigned short c)
10 {
11   c <<= __builtin_add_overflow (-c, -1, &b);
12   c >>= 1;
13   return c;
14 }
15 
16 __attribute__ ((noipa)) int
bar(unsigned short b)17 bar (unsigned short b)
18 {
19   b <<= -14 & 15;
20   b = b >> -~1;
21   return b;
22 }
23 
24 __attribute__ ((noipa)) int
baz(unsigned short e)25 baz (unsigned short e)
26 {
27   e <<= 1;
28   e >>= __builtin_add_overflow (8719476735, u, &v);
29   return e;
30 }
31 
32 __attribute__ ((noipa)) int
qux(unsigned int e)33 qux (unsigned int e)
34 {
35   c = ~1;
36   c *= e;
37   c = c >> (-15 & 5);
38   return c + w + x;
39 }
40 #endif
41 
42 int
main()43 main ()
44 {
45 #if __CHAR_BIT__ == 8 && __SIZEOF_SHORT__ == 2 \
46     && __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8
47   if (foo (0xffff) != 0x7fff)
48     __builtin_abort ();
49   if (bar (5) != 5)
50     __builtin_abort ();
51   if (baz (~0) != 0x7fff)
52     __builtin_abort ();
53   if (qux (2) != 0x7ffe)
54     __builtin_abort ();
55 #endif
56   return 0;
57 }
58