1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-- | FileCheck %s
6 ;#include <stdatomic.h>
11 ;void func(_Atomic(unsigned long) * obj, ptr obj2)
13 ; if (atomic_fetch_sub(obj, 1) == 1 && obj2)
17 define void @test_dec_select(ptr nocapture %0, ptr readnone %1) {
18 ; CHECK-LABEL: test_dec_select:
20 ; CHECK-NEXT: lock decq (%rdi)
21 ; CHECK-NEXT: jne .LBB0_2
22 ; CHECK-NEXT: # %bb.1:
23 ; CHECK-NEXT: testq %rsi, %rsi
24 ; CHECK-NEXT: jne func2 # TAILCALL
25 ; CHECK-NEXT: .LBB0_2:
27 %3 = atomicrmw sub ptr %0, i64 1 seq_cst
28 %4 = icmp eq i64 %3, 1
29 %5 = icmp ne ptr %1, null
30 %6 = select i1 %4, i1 %5, i1 false
31 br i1 %6, label %7, label %8
34 tail call void @func2()
41 define void @test_dec_select_commute(ptr nocapture %0, ptr readnone %1) {
42 ; CHECK-LABEL: test_dec_select_commute:
44 ; CHECK-NEXT: lock decq (%rdi)
45 ; CHECK-NEXT: sete %al
46 ; CHECK-NEXT: testq %rsi, %rsi
47 ; CHECK-NEXT: je .LBB1_2
48 ; CHECK-NEXT: # %bb.1:
49 ; CHECK-NEXT: testb %al, %al
50 ; CHECK-NEXT: jne func2 # TAILCALL
51 ; CHECK-NEXT: .LBB1_2:
53 %3 = atomicrmw sub ptr %0, i64 1 seq_cst
54 %4 = icmp eq i64 %3, 1
55 %5 = icmp ne ptr %1, null
56 %6 = select i1 %5, i1 %4, i1 false
57 br i1 %6, label %7, label %8
60 tail call void @func2()
67 define void @test_dec_and(ptr nocapture %0, ptr readnone %1) {
68 ; CHECK-LABEL: test_dec_and:
70 ; CHECK-NEXT: lock decq (%rdi)
71 ; CHECK-NEXT: sete %al
72 ; CHECK-NEXT: testq %rsi, %rsi
73 ; CHECK-NEXT: je .LBB2_2
74 ; CHECK-NEXT: # %bb.1:
75 ; CHECK-NEXT: testb %al, %al
76 ; CHECK-NEXT: jne func2 # TAILCALL
77 ; CHECK-NEXT: .LBB2_2:
79 %3 = atomicrmw sub ptr %0, i64 1 seq_cst
80 %4 = icmp eq i64 %3, 1
81 %5 = icmp ne ptr %1, null
83 br i1 %6, label %7, label %8
86 tail call void @func2()
93 define void @test_dec_and_commute(ptr nocapture %0, ptr readnone %1) {
94 ; CHECK-LABEL: test_dec_and_commute:
96 ; CHECK-NEXT: lock decq (%rdi)
97 ; CHECK-NEXT: jne .LBB3_2
98 ; CHECK-NEXT: # %bb.1:
99 ; CHECK-NEXT: testq %rsi, %rsi
100 ; CHECK-NEXT: jne func2 # TAILCALL
101 ; CHECK-NEXT: .LBB3_2:
103 %3 = atomicrmw sub ptr %0, i64 1 seq_cst
104 %4 = icmp eq i64 %3, 1
105 %5 = icmp ne ptr %1, null
107 br i1 %6, label %7, label %8
110 tail call void @func2()
117 declare dso_local void @func2()