1/* { dg-do compile } */
2/* { dg-require-effective-target lp64 } */
3/* { dg-options "-O" } */
4
5typedef int int32_t;
6
7int32_t round32hi (const __int128_t arg)
8{
9  const int SHIFT = 96;
10  const int mshift = 96;
11  const __int128_t M = (~(__int128_t) 0) << mshift;
12  const __int128_t L = (~M) + 1;
13  const __int128_t L1 = ((__int128_t) L) >> 1;
14  const __int128_t Mlo = ((__int128_t) (~M)) >> 1;
15  __int128_t vv = arg & M;
16
17  if ((arg & (L1)) && ((arg & Mlo) || (arg & L)))
18    vv += L;
19
20  return (int32_t) (vv >> SHIFT);
21}
22