(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
torture/
pr86438.c
       1  /* { dg-do run } */
       2  
       3  typedef unsigned int u32;
       4  #if __SIZEOF_INT128__
       5  typedef unsigned long long u64;
       6  typedef unsigned __int128 u128;
       7  #else
       8  typedef unsigned long u64;
       9  typedef unsigned long long u128;
      10  #endif
      11  
      12  u128 g;
      13  
      14  static __attribute__ ((noinline, noclone))
      15  void check (u64 a, u64 b)
      16  {
      17    if (a != 0 || b != 4)
      18      __builtin_abort ();
      19  }
      20  
      21  int
      22  main (void)
      23  {
      24    u64 d = (g ? 5 : 4);
      25    u32 f = __builtin_sub_overflow_p (d, (u128) d, (u64) 0);
      26    u128 x = g + f + d;
      27    check ((x >> 1) >> (sizeof (u64) * __CHAR_BIT__ - 1), x);
      28    return 0;
      29  }