1  /* PR target/98737 */
       2  /* { dg-do compile } */
       3  /* { dg-options "-O2 -masm=att" } */
       4  /* { dg-additional-options "-march=i686" { target ia32 } } */
       5  /* { dg-final { scan-assembler-not "lock\[^\n\rx]\*addq\t" } } */
       6  /* { dg-final { scan-assembler-not "lock\[^\n\rx]\*addl\t" } } */
       7  /* { dg-final { scan-assembler-not "lock\[^\n\rx]\*addw\t" } } */
       8  /* { dg-final { scan-assembler-not "lock\[^\n\rx]\*addb\t" } } */
       9  /* { dg-final { scan-assembler "lock\[^\n\r]\*xadd" } } */
      10  /* { dg-final { scan-assembler-not "lock\[^\n\r]\*cmpxchg" } } */
      11  
      12  long a;
      13  int b;
      14  short c;
      15  char d;
      16  
      17  int
      18  f1 (long x)
      19  {
      20    return __atomic_add_fetch (&a, x, __ATOMIC_RELEASE) <= 0;
      21  }
      22  
      23  int
      24  f2 (int x)
      25  {
      26    return __atomic_add_fetch (&b, x, __ATOMIC_RELEASE) <= 0;
      27  }
      28  
      29  int
      30  f3 (short x)
      31  {
      32    return __atomic_add_fetch (&c, x, __ATOMIC_RELEASE) <= 0;
      33  }
      34  
      35  int
      36  f4 (char x)
      37  {
      38    return __atomic_add_fetch (&d, x, __ATOMIC_RELEASE) <= 0;
      39  }
      40  
      41  int
      42  f5 (long x)
      43  {
      44    return __atomic_add_fetch (&a, x, __ATOMIC_RELEASE) > 0;
      45  }
      46  
      47  int
      48  f6 (int x)
      49  {
      50    return __atomic_add_fetch (&b, x, __ATOMIC_RELEASE) > 0;
      51  }
      52  
      53  int
      54  f7 (short x)
      55  {
      56    return __atomic_add_fetch (&c, x, __ATOMIC_RELEASE) > 0;
      57  }
      58  
      59  int
      60  f8 (char x)
      61  {
      62    return __atomic_add_fetch (&d, x, __ATOMIC_RELEASE) > 0;
      63  }
      64  
      65  int
      66  f9 (long x)
      67  {
      68    return __sync_add_and_fetch (&a, x) <= 0;
      69  }
      70  
      71  int
      72  f10 (int x)
      73  {
      74    return __sync_add_and_fetch (&b, x) <= 0;
      75  }
      76  
      77  int
      78  f11 (short x)
      79  {
      80    return __sync_add_and_fetch (&c, x) <= 0;
      81  }
      82  
      83  int
      84  f12 (char x)
      85  {
      86    return __sync_add_and_fetch (&d, x) <= 0;
      87  }
      88  
      89  int
      90  f13 (long x)
      91  {
      92    return __sync_add_and_fetch (&a, x) > 0;
      93  }
      94  
      95  int
      96  f14 (int x)
      97  {
      98    return __sync_add_and_fetch (&b, x) > 0;
      99  }
     100  
     101  int
     102  f15 (short x)
     103  {
     104    return __sync_add_and_fetch (&c, x) > 0;
     105  }
     106  
     107  int
     108  f16 (char x)
     109  {
     110    return __sync_add_and_fetch (&d, x) > 0;
     111  }