1  /* Test for correct rounding of conversions from __int128 to
       2     __float128.  */
       3  /* { dg-do run } */
       4  /* { dg-require-effective-target __float128 } */
       5  /* { dg-require-effective-target base_quadfloat_support } */
       6  /* { dg-require-effective-target int128 } */
       7  /* { dg-require-effective-target fenv } */
       8  /* { dg-options "-frounding-math" } */
       9  /* { dg-add-options __float128 } */
      10  
      11  #include <fenv.h>
      12  #include <stdlib.h>
      13  
      14  int
      15  main (void)
      16  {
      17    volatile unsigned long long h = -1ULL;
      18    volatile unsigned __int128 u128 = (((unsigned __int128) h) << 64) | h;
      19    volatile __int128 s128 = u128 >> 1;
      20    fesetround (FE_TOWARDZERO);
      21    __float128 ru = u128, rs = s128;
      22    if (ru != 0x1.ffffffffffffffffffffffffffffp127q)
      23      abort ();
      24    if (rs != 0x1.ffffffffffffffffffffffffffffp126q)
      25      abort ();
      26    exit (0);
      27  }