@@ -351,6 +351,19 @@ void inc_int(int* a, int b) {
351
351
// LLVM-LABEL: @_Z7inc_int
352
352
// LLVM: atomicrmw add ptr {{.*}}, i32 {{.*}} seq_cst, align 4
353
353
354
+ void sub_int (int * a, int b) {
355
+ int c = __sync_fetch_and_sub (a, b);
356
+ }
357
+
358
+ // CHECK-LABEL: _Z7sub_int
359
+ // CHECK: %[[PTR:.*]] = cir.load {{.*}} : !cir.ptr<!cir.ptr<!s32i>>, !cir.ptr<!s32i>
360
+ // CHECK: %[[VAL:.*]] = cir.load {{.*}} : !cir.ptr<!s32i>, !s32i
361
+ // CHECK: %[[RES:.*]] = cir.atomic.fetch(sub, %[[PTR]] : !cir.ptr<!s32i>, %[[VAL]] : !s32i, seq_cst) fetch_first : !s32i
362
+ // CHECK: cir.store %[[RES]], {{.*}} : !s32i, !cir.ptr<!s32i>
363
+
364
+ // LLVM-LABEL: _Z7sub_int
365
+ // LLVM: atomicrmw sub ptr {{.*}}, i32 {{.*}} seq_cst, align 4
366
+
354
367
355
368
// CHECK-LABEL: @_Z8inc_long
356
369
// CHECK: cir.atomic.fetch(add, {{.*}} : !cir.ptr<!s64i>, {{.*}} : !s64i, seq_cst) fetch_first : !s64i
@@ -362,6 +375,17 @@ void inc_long(long* a, long b) {
362
375
long c = __sync_fetch_and_add (a, 2 );
363
376
}
364
377
378
+ // CHECK-LABEL: @_Z8sub_long
379
+ // CHECK: cir.atomic.fetch(sub, {{.*}} : !cir.ptr<!s64i>, {{.*}} : !s64i, seq_cst) fetch_first : !s64i
380
+
381
+ // LLVM-LABEL: @_Z8sub_long
382
+ // LLVM: atomicrmw sub ptr {{.*}}, i64 {{.*}} seq_cst, align 8
383
+
384
+ void sub_long (long * a, long b) {
385
+ long c = __sync_fetch_and_sub (a, 2 );
386
+ }
387
+
388
+
365
389
// CHECK-LABEL: @_Z9inc_short
366
390
// CHECK: cir.atomic.fetch(add, {{.*}} : !cir.ptr<!s16i>, {{.*}} : !s16i, seq_cst) fetch_first : !s16i
367
391
@@ -371,6 +395,16 @@ void inc_short(short* a, short b) {
371
395
short c = __sync_fetch_and_add (a, 2 );
372
396
}
373
397
398
+ // CHECK-LABEL: @_Z9sub_short
399
+ // CHECK: cir.atomic.fetch(sub, {{.*}} : !cir.ptr<!s16i>, {{.*}} : !s16i, seq_cst) fetch_first : !s16i
400
+
401
+ // LLVM-LABEL: @_Z9sub_short
402
+ // LLVM: atomicrmw sub ptr {{.*}}, i16 {{.*}} seq_cst, align 2
403
+ void sub_short (short * a, short b) {
404
+ short c = __sync_fetch_and_sub (a, 2 );
405
+ }
406
+
407
+
374
408
// CHECK-LABEL: @_Z8inc_byte
375
409
// CHECK: cir.atomic.fetch(add, {{.*}} : !cir.ptr<!s8i>, {{.*}} : !s8i, seq_cst) fetch_first : !s8i
376
410
@@ -380,6 +414,14 @@ void inc_byte(char* a, char b) {
380
414
char c = __sync_fetch_and_add (a, b);
381
415
}
382
416
417
+ // CHECK-LABEL: @_Z8sub_byte
418
+ // CHECK: cir.atomic.fetch(sub, {{.*}} : !cir.ptr<!s8i>, {{.*}} : !s8i, seq_cst) fetch_first : !s8i
419
+
420
+ // LLVM-LABEL: @_Z8sub_byte
421
+ // LLVM: atomicrmw sub ptr {{.*}}, i8 {{.*}} seq_cst, align 1
422
+ void sub_byte (char * a, char b) {
423
+ char c = __sync_fetch_and_sub (a, b);
424
+ }
383
425
384
426
// CHECK-LABEL: @_Z12cmp_bool_int
385
427
// CHECK: %[[PTR:.*]] = cir.load {{.*}} : !cir.ptr<!cir.ptr<!s32i>>, !cir.ptr<!s32i>
@@ -481,6 +523,15 @@ void inc_uint(unsigned int* a, int b) {
481
523
unsigned int c = __sync_fetch_and_add (a, b);
482
524
}
483
525
526
+ // CHECK-LABEL: @_Z8sub_uint
527
+ // CHECK: cir.atomic.fetch(sub, {{.*}} : !cir.ptr<!u32i>, {{.*}} : !u32i, seq_cst) fetch_first : !u32i
528
+
529
+ // LLVM-LABEL: @_Z8sub_uint
530
+ // LLVM: atomicrmw sub ptr {{.*}}, i32 {{.*}} seq_cst, align 4
531
+ void sub_uint (unsigned int * a, int b) {
532
+ unsigned int c = __sync_fetch_and_sub (a, b);
533
+ }
534
+
484
535
// CHECK-LABEL: @_Z9inc_ulong
485
536
// CHECK: cir.atomic.fetch(add, {{.*}} : !cir.ptr<!u64i>, {{.*}} : !u64i, seq_cst) fetch_first : !u64i
486
537
@@ -490,11 +541,30 @@ void inc_ulong(unsigned long* a, long b) {
490
541
unsigned long c = __sync_fetch_and_add (a, b);
491
542
}
492
543
544
+ // CHECK-LABEL: @_Z9sub_ulong
545
+ // CHECK: cir.atomic.fetch(sub, {{.*}} : !cir.ptr<!u64i>, {{.*}} : !u64i, seq_cst) fetch_first : !u64i
546
+
547
+ // LLVM-LABEL: @_Z9sub_ulong
548
+ // LLVM: atomicrmw sub ptr {{.*}}, i64 {{.*}} seq_cst, align 8
549
+ void sub_ulong (unsigned long * a, long b) {
550
+ unsigned long c = __sync_fetch_and_sub (a, b);
551
+ }
552
+
553
+
493
554
// CHECK-LABEL: @_Z9inc_uchar
494
555
// CHECK: cir.atomic.fetch(add, {{.*}} : !cir.ptr<!u8i>, {{.*}} : !u8i, seq_cst) fetch_first : !u8i
495
556
496
557
// LLVM-LABEL: @_Z9inc_uchar
497
558
// LLVM: atomicrmw add ptr {{.*}}, i8 {{.*}} seq_cst, align 1
498
559
void inc_uchar (unsigned char * a, char b) {
499
560
unsigned char c = __sync_fetch_and_add (a, b);
500
- }
561
+ }
562
+
563
+ // CHECK-LABEL: @_Z9sub_uchar
564
+ // CHECK: cir.atomic.fetch(sub, {{.*}} : !cir.ptr<!u8i>, {{.*}} : !u8i, seq_cst) fetch_first : !u8i
565
+
566
+ // LLVM-LABEL: @_Z9sub_uchar
567
+ // LLVM: atomicrmw sub ptr {{.*}}, i8 {{.*}} seq_cst, align 1
568
+ void sub_uchar (unsigned char * a, char b) {
569
+ unsigned char c = __sync_fetch_and_sub (a, b);
570
+ }
0 commit comments