1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-apple-darwin19.6.0 | FileCheck %s --check-prefix=SSE2
3 ; RUN: llc < %s -mtriple=x86_64-apple-darwin19.6.0 -mattr=avx | FileCheck %s --check-prefix=AVX
4 ; RUN: llc < %s -mtriple=x86_64-apple-darwin19.6.0 -mattr=avx512f | FileCheck %s --check-prefix=AVX
6 define void @a(ptr %arg, i32 %arg1) {
8 ; SSE2: ## %bb.0: ## %bb
9 ; SSE2-NEXT: testl %esi, %esi
10 ; SSE2-NEXT: jle LBB0_3
11 ; SSE2-NEXT: ## %bb.1: ## %bb2
12 ; SSE2-NEXT: movl %esi, {{[-0-9]+}}(%r{{[sb]}}p) ## 4-byte Spill
13 ; SSE2-NEXT: movl %esi, %eax
14 ; SSE2-NEXT: .p2align 4, 0x90
15 ; SSE2-NEXT: LBB0_2: ## %bb6
16 ; SSE2-NEXT: ## =>This Inner Loop Header: Depth=1
17 ; SSE2-NEXT: ## InlineAsm Start
18 ; SSE2-NEXT: ## InlineAsm End
19 ; SSE2-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
20 ; SSE2-NEXT: addss {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 ## 4-byte Folded Reload
21 ; SSE2-NEXT: movss %xmm0, (%rdi)
22 ; SSE2-NEXT: addq $4, %rdi
23 ; SSE2-NEXT: decq %rax
24 ; SSE2-NEXT: jne LBB0_2
25 ; SSE2-NEXT: LBB0_3: ## %bb5
29 ; AVX: ## %bb.0: ## %bb
30 ; AVX-NEXT: testl %esi, %esi
31 ; AVX-NEXT: jle LBB0_3
32 ; AVX-NEXT: ## %bb.1: ## %bb2
33 ; AVX-NEXT: movl %esi, {{[-0-9]+}}(%r{{[sb]}}p) ## 4-byte Spill
34 ; AVX-NEXT: movl %esi, %eax
35 ; AVX-NEXT: .p2align 4, 0x90
36 ; AVX-NEXT: LBB0_2: ## %bb6
37 ; AVX-NEXT: ## =>This Inner Loop Header: Depth=1
38 ; AVX-NEXT: ## InlineAsm Start
39 ; AVX-NEXT: ## InlineAsm End
40 ; AVX-NEXT: vmovss {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 ## 4-byte Reload
41 ; AVX-NEXT: ## xmm0 = mem[0],zero,zero,zero
42 ; AVX-NEXT: vaddss (%rdi), %xmm0, %xmm0
43 ; AVX-NEXT: vmovss %xmm0, (%rdi)
44 ; AVX-NEXT: addq $4, %rdi
46 ; AVX-NEXT: jne LBB0_2
47 ; AVX-NEXT: LBB0_3: ## %bb5
50 %i = icmp sgt i32 %arg1, 0
51 br i1 %i, label %bb2, label %bb5
54 %i3 = bitcast i32 %arg1 to float
55 %i4 = zext i32 %arg1 to i64
58 bb5: ; preds = %bb6, %bb
61 bb6: ; preds = %bb6, %bb2
62 %i7 = phi i64 [ 0, %bb2 ], [ %i11, %bb6 ]
63 tail call void asm sideeffect "", "~{xmm0},~{xmm1},~{xmm2},~{xmm3},~{xmm4},~{xmm5},~{xmm6},~{xmm7},~{xmm8},~{xmm9},~{xmm10},~{xmm11},~{xmm12},~{xmm13},~{xmm14},~{xmm15},~{xmm16},~{xmm17},~{xmm18},~{xmm19},~{xmm20},~{xmm21},~{xmm22},~{xmm23},~{xmm24},~{xmm25},~{xmm26},~{xmm27},~{xmm28},~{xmm29},~{xmm30},~{xmm31},~{dirflag},~{fpsr},~{flags}"()
64 %i8 = getelementptr inbounds float, ptr %arg, i64 %i7
65 %i9 = load float, ptr %i8, align 4
66 %i10 = fadd float %i9, %i3
67 store float %i10, ptr %i8, align 4
68 %i11 = add nuw nsw i64 %i7, 1
69 %i12 = icmp eq i64 %i11, %i4
70 br i1 %i12, label %bb5, label %bb6
73 define void @b(ptr %arg, i64 %arg1) {
75 ; SSE2: ## %bb.0: ## %bb
76 ; SSE2-NEXT: testq %rsi, %rsi
77 ; SSE2-NEXT: jle LBB1_3
78 ; SSE2-NEXT: ## %bb.1: ## %bb2
79 ; SSE2-NEXT: movq %rsi, {{[-0-9]+}}(%r{{[sb]}}p) ## 8-byte Spill
80 ; SSE2-NEXT: .p2align 4, 0x90
81 ; SSE2-NEXT: LBB1_2: ## %bb6
82 ; SSE2-NEXT: ## =>This Inner Loop Header: Depth=1
83 ; SSE2-NEXT: ## InlineAsm Start
84 ; SSE2-NEXT: ## InlineAsm End
85 ; SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
86 ; SSE2-NEXT: addsd {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 ## 8-byte Folded Reload
87 ; SSE2-NEXT: movsd %xmm0, (%rdi)
88 ; SSE2-NEXT: addq $8, %rdi
89 ; SSE2-NEXT: decq %rsi
90 ; SSE2-NEXT: jne LBB1_2
91 ; SSE2-NEXT: LBB1_3: ## %bb5
95 ; AVX: ## %bb.0: ## %bb
96 ; AVX-NEXT: testq %rsi, %rsi
97 ; AVX-NEXT: jle LBB1_3
98 ; AVX-NEXT: ## %bb.1: ## %bb2
99 ; AVX-NEXT: movq %rsi, {{[-0-9]+}}(%r{{[sb]}}p) ## 8-byte Spill
100 ; AVX-NEXT: .p2align 4, 0x90
101 ; AVX-NEXT: LBB1_2: ## %bb6
102 ; AVX-NEXT: ## =>This Inner Loop Header: Depth=1
103 ; AVX-NEXT: ## InlineAsm Start
104 ; AVX-NEXT: ## InlineAsm End
105 ; AVX-NEXT: vmovsd {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 ## 8-byte Reload
106 ; AVX-NEXT: ## xmm0 = mem[0],zero
107 ; AVX-NEXT: vaddsd (%rdi), %xmm0, %xmm0
108 ; AVX-NEXT: vmovsd %xmm0, (%rdi)
109 ; AVX-NEXT: addq $8, %rdi
110 ; AVX-NEXT: decq %rsi
111 ; AVX-NEXT: jne LBB1_2
112 ; AVX-NEXT: LBB1_3: ## %bb5
115 %i = icmp sgt i64 %arg1, 0
116 br i1 %i, label %bb2, label %bb5
119 %i3 = bitcast i64 %arg1 to double
122 bb5: ; preds = %bb6, %bb
125 bb6: ; preds = %bb6, %bb2
126 %i7 = phi i64 [ 0, %bb2 ], [ %i11, %bb6 ]
127 tail call void asm sideeffect "", "~{xmm0},~{xmm1},~{xmm2},~{xmm3},~{xmm4},~{xmm5},~{xmm6},~{xmm7},~{xmm8},~{xmm9},~{xmm10},~{xmm11},~{xmm12},~{xmm13},~{xmm14},~{xmm15},~{xmm16},~{xmm17},~{xmm18},~{xmm19},~{xmm20},~{xmm21},~{xmm22},~{xmm23},~{xmm24},~{xmm25},~{xmm26},~{xmm27},~{xmm28},~{xmm29},~{xmm30},~{xmm31},~{dirflag},~{fpsr},~{flags}"()
128 %i8 = getelementptr inbounds double, ptr %arg, i64 %i7
129 %i9 = load double, ptr %i8, align 4
130 %i10 = fadd double %i9, %i3
131 store double %i10, ptr %i8, align 4
132 %i11 = add nuw nsw i64 %i7, 1
133 %i12 = icmp eq i64 %i11, %arg1
134 br i1 %i12, label %bb5, label %bb6
137 define void @c(ptr %arg, ptr %arg1, i32 %arg2) {
139 ; SSE2: ## %bb.0: ## %bb
140 ; SSE2-NEXT: testl %edx, %edx
141 ; SSE2-NEXT: jle LBB2_3
142 ; SSE2-NEXT: ## %bb.1: ## %bb4
143 ; SSE2-NEXT: movl %edx, {{[-0-9]+}}(%r{{[sb]}}p) ## 4-byte Spill
144 ; SSE2-NEXT: movl %edx, %eax
145 ; SSE2-NEXT: .p2align 4, 0x90
146 ; SSE2-NEXT: LBB2_2: ## %bb8
147 ; SSE2-NEXT: ## =>This Inner Loop Header: Depth=1
148 ; SSE2-NEXT: ## InlineAsm Start
149 ; SSE2-NEXT: ## InlineAsm End
150 ; SSE2-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
151 ; SSE2-NEXT: addss {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 ## 4-byte Folded Reload
152 ; SSE2-NEXT: movss %xmm0, (%rdi)
153 ; SSE2-NEXT: addq $16, %rdi
154 ; SSE2-NEXT: decq %rax
155 ; SSE2-NEXT: jne LBB2_2
156 ; SSE2-NEXT: LBB2_3: ## %bb7
160 ; AVX: ## %bb.0: ## %bb
161 ; AVX-NEXT: testl %edx, %edx
162 ; AVX-NEXT: jle LBB2_3
163 ; AVX-NEXT: ## %bb.1: ## %bb4
164 ; AVX-NEXT: movl %edx, {{[-0-9]+}}(%r{{[sb]}}p) ## 4-byte Spill
165 ; AVX-NEXT: movl %edx, %eax
166 ; AVX-NEXT: .p2align 4, 0x90
167 ; AVX-NEXT: LBB2_2: ## %bb8
168 ; AVX-NEXT: ## =>This Inner Loop Header: Depth=1
169 ; AVX-NEXT: ## InlineAsm Start
170 ; AVX-NEXT: ## InlineAsm End
171 ; AVX-NEXT: vmovss {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 ## 4-byte Reload
172 ; AVX-NEXT: ## xmm0 = mem[0],zero,zero,zero
173 ; AVX-NEXT: vaddss (%rdi), %xmm0, %xmm0
174 ; AVX-NEXT: vmovss %xmm0, (%rdi)
175 ; AVX-NEXT: addq $16, %rdi
176 ; AVX-NEXT: decq %rax
177 ; AVX-NEXT: jne LBB2_2
178 ; AVX-NEXT: LBB2_3: ## %bb7
181 %i = icmp sgt i32 %arg2, 0
182 br i1 %i, label %bb4, label %bb7
185 %i5 = bitcast i32 %arg2 to float
186 %i6 = zext i32 %arg2 to i64
189 bb7: ; preds = %bb8, %bb
192 bb8: ; preds = %bb8, %bb4
193 %i9 = phi i64 [ 0, %bb4 ], [ %i15, %bb8 ]
194 tail call void asm sideeffect "", "~{xmm0},~{xmm1},~{xmm2},~{xmm3},~{xmm4},~{xmm5},~{xmm6},~{xmm7},~{xmm8},~{xmm9},~{xmm10},~{xmm11},~{xmm12},~{xmm13},~{xmm14},~{xmm15},~{xmm16},~{xmm17},~{xmm18},~{xmm19},~{xmm20},~{xmm21},~{xmm22},~{xmm23},~{xmm24},~{xmm25},~{xmm26},~{xmm27},~{xmm28},~{xmm29},~{xmm30},~{xmm31},~{dirflag},~{fpsr},~{flags}"()
195 %i10 = getelementptr inbounds <4 x float>, ptr %arg, i64 %i9
196 %i11 = load <4 x float>, ptr %i10, align 16
197 %i12 = extractelement <4 x float> %i11, i32 0
198 %i13 = fadd float %i12, %i5
199 %i14 = insertelement <4 x float> %i11, float %i13, i32 0
200 store <4 x float> %i14, ptr %i10, align 16
201 %i15 = add nuw nsw i64 %i9, 1
202 %i16 = icmp eq i64 %i15, %i6
203 br i1 %i16, label %bb7, label %bb8
206 define void @d(ptr %arg, ptr %arg1, i64 %arg2) {
208 ; SSE2: ## %bb.0: ## %bb
209 ; SSE2-NEXT: testq %rdx, %rdx
210 ; SSE2-NEXT: jle LBB3_3
211 ; SSE2-NEXT: ## %bb.1: ## %bb3
212 ; SSE2-NEXT: movq %rdx, {{[-0-9]+}}(%r{{[sb]}}p) ## 8-byte Spill
213 ; SSE2-NEXT: .p2align 4, 0x90
214 ; SSE2-NEXT: LBB3_2: ## %bb6
215 ; SSE2-NEXT: ## =>This Inner Loop Header: Depth=1
216 ; SSE2-NEXT: ## InlineAsm Start
217 ; SSE2-NEXT: ## InlineAsm End
218 ; SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
219 ; SSE2-NEXT: addsd {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 ## 8-byte Folded Reload
220 ; SSE2-NEXT: movsd %xmm0, (%rdi)
221 ; SSE2-NEXT: addq $16, %rdi
222 ; SSE2-NEXT: decq %rdx
223 ; SSE2-NEXT: jne LBB3_2
224 ; SSE2-NEXT: LBB3_3: ## %bb5
228 ; AVX: ## %bb.0: ## %bb
229 ; AVX-NEXT: testq %rdx, %rdx
230 ; AVX-NEXT: jle LBB3_3
231 ; AVX-NEXT: ## %bb.1: ## %bb3
232 ; AVX-NEXT: movq %rdx, {{[-0-9]+}}(%r{{[sb]}}p) ## 8-byte Spill
233 ; AVX-NEXT: .p2align 4, 0x90
234 ; AVX-NEXT: LBB3_2: ## %bb6
235 ; AVX-NEXT: ## =>This Inner Loop Header: Depth=1
236 ; AVX-NEXT: ## InlineAsm Start
237 ; AVX-NEXT: ## InlineAsm End
238 ; AVX-NEXT: vmovsd {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 ## 8-byte Reload
239 ; AVX-NEXT: ## xmm0 = mem[0],zero
240 ; AVX-NEXT: vaddsd (%rdi), %xmm0, %xmm0
241 ; AVX-NEXT: vmovsd %xmm0, (%rdi)
242 ; AVX-NEXT: addq $16, %rdi
243 ; AVX-NEXT: decq %rdx
244 ; AVX-NEXT: jne LBB3_2
245 ; AVX-NEXT: LBB3_3: ## %bb5
248 %i = icmp sgt i64 %arg2, 0
249 br i1 %i, label %bb3, label %bb5
252 %i4 = bitcast i64 %arg2 to double
255 bb5: ; preds = %bb6, %bb
258 bb6: ; preds = %bb6, %bb3
259 %i7 = phi i64 [ 0, %bb3 ], [ %i13, %bb6 ]
260 tail call void asm sideeffect "", "~{xmm0},~{xmm1},~{xmm2},~{xmm3},~{xmm4},~{xmm5},~{xmm6},~{xmm7},~{xmm8},~{xmm9},~{xmm10},~{xmm11},~{xmm12},~{xmm13},~{xmm14},~{xmm15},~{xmm16},~{xmm17},~{xmm18},~{xmm19},~{xmm20},~{xmm21},~{xmm22},~{xmm23},~{xmm24},~{xmm25},~{xmm26},~{xmm27},~{xmm28},~{xmm29},~{xmm30},~{xmm31},~{dirflag},~{fpsr},~{flags}"()
261 %i8 = getelementptr inbounds <2 x double>, ptr %arg, i64 %i7
262 %i9 = load <2 x double>, ptr %i8, align 16
263 %i10 = extractelement <2 x double> %i9, i32 0
264 %i11 = fadd double %i10, %i4
265 %i12 = insertelement <2 x double> %i9, double %i11, i32 0
266 store <2 x double> %i12, ptr %i8, align 16
267 %i13 = add nuw nsw i64 %i7, 1
268 %i14 = icmp eq i64 %i13, %arg2
269 br i1 %i14, label %bb5, label %bb6