1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-apple-macosx | FileCheck %s
4 define i32 @test_01(ptr %p, i64 %len, i32 %x) {
5 ; CHECK-LABEL: test_01:
6 ; CHECK: ## %bb.0: ## %entry
7 ; CHECK-NEXT: .p2align 4, 0x90
8 ; CHECK-NEXT: LBB0_1: ## %loop
9 ; CHECK-NEXT: ## =>This Inner Loop Header: Depth=1
10 ; CHECK-NEXT: subq $1, %rsi
11 ; CHECK-NEXT: jb LBB0_4
12 ; CHECK-NEXT: ## %bb.2: ## %backedge
13 ; CHECK-NEXT: ## in Loop: Header=BB0_1 Depth=1
14 ; CHECK-NEXT: cmpl %edx, (%rdi,%rsi,4)
15 ; CHECK-NEXT: jne LBB0_1
16 ; CHECK-NEXT: ## %bb.3: ## %failure
18 ; CHECK-NEXT: LBB0_4: ## %exit
19 ; CHECK-NEXT: movl $-1, %eax
24 loop: ; preds = %backedge, %entry
25 %iv = phi i64 [ %iv.next, %backedge ], [ %len, %entry ]
26 %iv.next = add nsw i64 %iv, -1
27 %cond_1 = icmp eq i64 %iv, 0
28 br i1 %cond_1, label %exit, label %backedge
30 backedge: ; preds = %loop
31 %addr = getelementptr inbounds i32, ptr %p, i64 %iv.next
32 %loaded = load atomic i32, ptr %addr unordered, align 4
33 %cond_2 = icmp eq i32 %loaded, %x
34 br i1 %cond_2, label %failure, label %loop
39 failure: ; preds = %backedge
43 ; Similar to test_01, but we use offsetted pointer as base.
44 define i32 @test_01a(ptr %p, i64 %len, i32 %x) {
45 ; CHECK-LABEL: test_01a:
46 ; CHECK: ## %bb.0: ## %entry
47 ; CHECK-NEXT: .p2align 4, 0x90
48 ; CHECK-NEXT: LBB1_1: ## %loop
49 ; CHECK-NEXT: ## =>This Inner Loop Header: Depth=1
50 ; CHECK-NEXT: subq $1, %rsi
51 ; CHECK-NEXT: jb LBB1_4
52 ; CHECK-NEXT: ## %bb.2: ## %backedge
53 ; CHECK-NEXT: ## in Loop: Header=BB1_1 Depth=1
54 ; CHECK-NEXT: cmpl %edx, -24(%rdi,%rsi,4)
55 ; CHECK-NEXT: jne LBB1_1
56 ; CHECK-NEXT: ## %bb.3: ## %failure
58 ; CHECK-NEXT: LBB1_4: ## %exit
59 ; CHECK-NEXT: movl $-1, %eax
62 %base = getelementptr inbounds i32, ptr %p, i64 -6
65 loop: ; preds = %backedge, %entry
66 %iv = phi i64 [ %iv.next, %backedge ], [ %len, %entry ]
67 %iv.next = add nsw i64 %iv, -1
68 %cond_1 = icmp eq i64 %iv, 0
69 br i1 %cond_1, label %exit, label %backedge
71 backedge: ; preds = %loop
72 %addr = getelementptr inbounds i32, ptr %base, i64 %iv.next
73 %loaded = load atomic i32, ptr %addr unordered, align 4
74 %cond_2 = icmp eq i32 %loaded, %x
75 br i1 %cond_2, label %failure, label %loop
80 failure: ; preds = %backedge
84 define i32 @test_02(ptr %p, i64 %len, i32 %x) {
85 ; CHECK-LABEL: test_02:
86 ; CHECK: ## %bb.0: ## %entry
87 ; CHECK-NEXT: .p2align 4, 0x90
88 ; CHECK-NEXT: LBB2_1: ## %loop
89 ; CHECK-NEXT: ## =>This Inner Loop Header: Depth=1
90 ; CHECK-NEXT: subq $1, %rsi
91 ; CHECK-NEXT: jb LBB2_4
92 ; CHECK-NEXT: ## %bb.2: ## %backedge
93 ; CHECK-NEXT: ## in Loop: Header=BB2_1 Depth=1
94 ; CHECK-NEXT: cmpl %edx, (%rdi,%rsi,4)
95 ; CHECK-NEXT: jne LBB2_1
96 ; CHECK-NEXT: ## %bb.3: ## %failure
98 ; CHECK-NEXT: LBB2_4: ## %exit
99 ; CHECK-NEXT: movl $-1, %eax
102 %start = add i64 %len, -1
105 loop: ; preds = %backedge, %entry
106 %iv = phi i64 [ %iv.next, %backedge ], [ %start, %entry ]
107 %iv.next = add nsw i64 %iv, -1
108 %iv.offset = add i64 %iv, 1
109 %iv.next.offset = add i64 %iv.next, 1
110 %cond_1 = icmp eq i64 %iv.offset, 0
111 br i1 %cond_1, label %exit, label %backedge
113 backedge: ; preds = %loop
114 %addr = getelementptr inbounds i32, ptr %p, i64 %iv.next.offset
115 %loaded = load atomic i32, ptr %addr unordered, align 4
116 %cond_2 = icmp eq i32 %loaded, %x
117 br i1 %cond_2, label %failure, label %loop
119 exit: ; preds = %loop
122 failure: ; preds = %backedge
126 define i32 @test_03(ptr %p, i64 %len, i32 %x) {
127 ; CHECK-LABEL: test_03:
128 ; CHECK: ## %bb.0: ## %entry
129 ; CHECK-NEXT: .p2align 4, 0x90
130 ; CHECK-NEXT: LBB3_1: ## %loop
131 ; CHECK-NEXT: ## =>This Inner Loop Header: Depth=1
132 ; CHECK-NEXT: subq $1, %rsi
133 ; CHECK-NEXT: jb LBB3_4
134 ; CHECK-NEXT: ## %bb.2: ## %backedge
135 ; CHECK-NEXT: ## in Loop: Header=BB3_1 Depth=1
136 ; CHECK-NEXT: cmpl %edx, (%rdi,%rsi,4)
137 ; CHECK-NEXT: jne LBB3_1
138 ; CHECK-NEXT: ## %bb.3: ## %failure
140 ; CHECK-NEXT: LBB3_4: ## %exit
141 ; CHECK-NEXT: movl $-1, %eax
144 %start = add i64 %len, -100
147 loop: ; preds = %backedge, %entry
148 %iv = phi i64 [ %iv.next, %backedge ], [ %start, %entry ]
149 %iv.next = add nsw i64 %iv, -1
150 %iv.offset = add i64 %iv, 100
151 %iv.next.offset = add i64 %iv.next, 100
152 %cond_1 = icmp eq i64 %iv.offset, 0
153 br i1 %cond_1, label %exit, label %backedge
155 backedge: ; preds = %loop
156 %addr = getelementptr inbounds i32, ptr %p, i64 %iv.next.offset
157 %loaded = load atomic i32, ptr %addr unordered, align 4
158 %cond_2 = icmp eq i32 %loaded, %x
159 br i1 %cond_2, label %failure, label %loop
161 exit: ; preds = %loop
164 failure: ; preds = %backedge
168 define void @test_04() {
169 ; CHECK-LABEL: test_04:
170 ; CHECK: ## %bb.0: ## %bb
175 bb1: ; preds = %bb10, %bb
176 %tmp = phi i64 [ 1, %bb ], [ %tmp2, %bb10 ]
177 %tmp2 = add nuw nsw i64 %tmp, 1
178 br i1 undef, label %bb21, label %bb7
181 %tmp8 = add nsw i64 %tmp, -1
182 %tmp9 = getelementptr inbounds i32, ptr addrspace(1) undef, i64 %tmp8
183 store atomic i32 undef, ptr addrspace(1) %tmp9 unordered, align 4
186 bb10: ; preds = %bb16
189 bb11: ; preds = %bb16, %bb7
190 switch i32 undef, label %bb19 [
198 bb12: ; preds = %bb11
201 bb14: ; preds = %bb11
204 bb15: ; preds = %bb11
207 bb16: ; preds = %bb11
208 br i1 undef, label %bb10, label %bb11
210 bb17: ; preds = %bb11
213 bb19: ; preds = %bb11