(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.c-torture/
execute/
pr85095.c
       1  /* PR target/85095 */
       2  
       3  __attribute__((noipa)) unsigned long
       4  f1 (unsigned long a, unsigned long b)
       5  {
       6    unsigned long i = __builtin_add_overflow (a, b, &a);
       7    return a + i;
       8  }
       9  
      10  __attribute__((noipa)) unsigned long
      11  f2 (unsigned long a, unsigned long b)
      12  {
      13    unsigned long i = __builtin_add_overflow (a, b, &a);
      14    return a - i;
      15  }
      16  
      17  __attribute__((noipa)) unsigned long
      18  f3 (unsigned int a, unsigned int b)
      19  {
      20    unsigned int i = __builtin_add_overflow (a, b, &a);
      21    return a + i;
      22  }
      23  
      24  __attribute__((noipa)) unsigned long
      25  f4 (unsigned int a, unsigned int b)
      26  {
      27    unsigned int i = __builtin_add_overflow (a, b, &a);
      28    return a - i;
      29  }
      30  
      31  int
      32  main ()
      33  {
      34    if (f1 (16UL, -18UL) != -2UL
      35        || f1 (16UL, -17UL) != -1UL
      36        || f1 (16UL, -16UL) != 1UL
      37        || f1 (16UL, -15UL) != 2UL
      38        || f2 (24UL, -26UL) != -2UL
      39        || f2 (24UL, -25UL) != -1UL
      40        || f2 (24UL, -24UL) != -1UL
      41        || f2 (24UL, -23UL) != 0UL
      42        || f3 (32U, -34U) != -2U
      43        || f3 (32U, -33U) != -1U
      44        || f3 (32U, -32U) != 1U
      45        || f3 (32U, -31U) != 2U
      46        || f4 (35U, -37U) != -2U
      47        || f4 (35U, -36U) != -1U
      48        || f4 (35U, -35U) != -1U
      49        || f4 (35U, -34U) != 0U)
      50      __builtin_abort ();
      51    return 0;
      52  }