1 /* PR target/85582 */
2 
3 #ifdef __SIZEOF_INT128__
4 typedef __int128 S;
5 typedef unsigned __int128 U;
6 #else
7 typedef long long S;
8 typedef unsigned long long U;
9 #endif
10 
11 __attribute__((noipa)) U
f1(U x,int y)12 f1 (U x, int y)
13 {
14   return x << (y & -2);
15 }
16 
17 __attribute__((noipa)) S
f2(S x,int y)18 f2 (S x, int y)
19 {
20   return x >> (y & -2);
21 }
22 
23 __attribute__((noipa)) U
f3(U x,int y)24 f3 (U x, int y)
25 {
26   return x >> (y & -2);
27 }
28 
29 int
main()30 main ()
31 {
32   U a = (U) 1 << (sizeof (U) * __CHAR_BIT__ - 7);
33   if (f1 (a, 5) != ((U) 1 << (sizeof (S) * __CHAR_BIT__ - 3)))
34     __builtin_abort ();
35   S b = (U) 0x101 << (sizeof (S) * __CHAR_BIT__ / 2 - 7);
36   if (f1 (b, sizeof (S) * __CHAR_BIT__ / 2) != (U) 0x101 << (sizeof (S) * __CHAR_BIT__ - 7))
37     __builtin_abort ();
38   if (f1 (b, sizeof (S) * __CHAR_BIT__ / 2 + 2) != (U) 0x101 << (sizeof (S) * __CHAR_BIT__ - 5))
39     __builtin_abort ();
40   S c = (U) 1 << (sizeof (S) * __CHAR_BIT__ - 1);
41   if ((U) f2 (c, 5) != ((U) 0x1f << (sizeof (S) * __CHAR_BIT__ - 5)))
42     __builtin_abort ();
43   if ((U) f2 (c, sizeof (S) * __CHAR_BIT__ / 2) != ((U) -1 << (sizeof (S) * __CHAR_BIT__ / 2 - 1)))
44     __builtin_abort ();
45   if ((U) f2 (c, sizeof (S) * __CHAR_BIT__ / 2 + 2) != ((U) -1 << (sizeof (S) * __CHAR_BIT__ / 2 - 3)))
46     __builtin_abort ();
47   U d = (U) 1 << (sizeof (S) * __CHAR_BIT__ - 1);
48   if (f3 (c, 5) != ((U) 0x1 << (sizeof (S) * __CHAR_BIT__ - 5)))
49     __builtin_abort ();
50   if (f3 (c, sizeof (S) * __CHAR_BIT__ / 2) != ((U) 1 << (sizeof (S) * __CHAR_BIT__ / 2 - 1)))
51     __builtin_abort ();
52   if (f3 (c, sizeof (S) * __CHAR_BIT__ / 2 + 2) != ((U) 1 << (sizeof (S) * __CHAR_BIT__ / 2 - 3)))
53     __builtin_abort ();
54   return 0;
55 }
56