1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=arm64-linux-gnu -verify-machineinstrs -mcpu=cyclone -aarch64-enable-atomic-cfg-tidy=0 < %s | FileCheck -enable-var-scope %s
4 @lhs = dso_local global fp128 zeroinitializer, align 16
5 @rhs = dso_local global fp128 zeroinitializer, align 16
7 define fp128 @test_add() {
8 ; CHECK-LABEL: test_add:
10 ; CHECK-NEXT: adrp x8, lhs
11 ; CHECK-NEXT: ldr q0, [x8, :lo12:lhs]
12 ; CHECK-NEXT: adrp x8, rhs
13 ; CHECK-NEXT: ldr q1, [x8, :lo12:rhs]
14 ; CHECK-NEXT: b __addtf3
16 %lhs = load fp128, ptr @lhs, align 16
17 %rhs = load fp128, ptr @rhs, align 16
19 %val = fadd fp128 %lhs, %rhs
23 define fp128 @test_sub() {
24 ; CHECK-LABEL: test_sub:
26 ; CHECK-NEXT: adrp x8, lhs
27 ; CHECK-NEXT: ldr q0, [x8, :lo12:lhs]
28 ; CHECK-NEXT: adrp x8, rhs
29 ; CHECK-NEXT: ldr q1, [x8, :lo12:rhs]
30 ; CHECK-NEXT: b __subtf3
32 %lhs = load fp128, ptr @lhs, align 16
33 %rhs = load fp128, ptr @rhs, align 16
35 %val = fsub fp128 %lhs, %rhs
39 define fp128 @test_mul() {
40 ; CHECK-LABEL: test_mul:
42 ; CHECK-NEXT: adrp x8, lhs
43 ; CHECK-NEXT: ldr q0, [x8, :lo12:lhs]
44 ; CHECK-NEXT: adrp x8, rhs
45 ; CHECK-NEXT: ldr q1, [x8, :lo12:rhs]
46 ; CHECK-NEXT: b __multf3
48 %lhs = load fp128, ptr @lhs, align 16
49 %rhs = load fp128, ptr @rhs, align 16
51 %val = fmul fp128 %lhs, %rhs
55 define fp128 @test_div() {
56 ; CHECK-LABEL: test_div:
58 ; CHECK-NEXT: adrp x8, lhs
59 ; CHECK-NEXT: ldr q0, [x8, :lo12:lhs]
60 ; CHECK-NEXT: adrp x8, rhs
61 ; CHECK-NEXT: ldr q1, [x8, :lo12:rhs]
62 ; CHECK-NEXT: b __divtf3
64 %lhs = load fp128, ptr @lhs, align 16
65 %rhs = load fp128, ptr @rhs, align 16
67 %val = fdiv fp128 %lhs, %rhs
71 @var32 = dso_local global i32 0
72 @var64 = dso_local global i64 0
74 define dso_local void @test_fptosi() {
75 ; CHECK-LABEL: test_fptosi:
77 ; CHECK-NEXT: sub sp, sp, #32
78 ; CHECK-NEXT: str x30, [sp, #16] // 8-byte Folded Spill
79 ; CHECK-NEXT: .cfi_def_cfa_offset 32
80 ; CHECK-NEXT: .cfi_offset w30, -16
81 ; CHECK-NEXT: adrp x8, lhs
82 ; CHECK-NEXT: ldr q0, [x8, :lo12:lhs]
83 ; CHECK-NEXT: str q0, [sp] // 16-byte Folded Spill
84 ; CHECK-NEXT: bl __fixtfsi
85 ; CHECK-NEXT: adrp x8, var32
86 ; CHECK-NEXT: str w0, [x8, :lo12:var32]
87 ; CHECK-NEXT: ldr q0, [sp] // 16-byte Folded Reload
88 ; CHECK-NEXT: bl __fixtfdi
89 ; CHECK-NEXT: adrp x8, var64
90 ; CHECK-NEXT: str x0, [x8, :lo12:var64]
91 ; CHECK-NEXT: ldr x30, [sp, #16] // 8-byte Folded Reload
92 ; CHECK-NEXT: add sp, sp, #32
94 %val = load fp128, ptr @lhs, align 16
96 %val32 = fptosi fp128 %val to i32
97 store i32 %val32, ptr @var32
99 %val64 = fptosi fp128 %val to i64
100 store i64 %val64, ptr @var64
105 define dso_local void @test_fptoui() {
106 ; CHECK-LABEL: test_fptoui:
108 ; CHECK-NEXT: sub sp, sp, #32
109 ; CHECK-NEXT: str x30, [sp, #16] // 8-byte Folded Spill
110 ; CHECK-NEXT: .cfi_def_cfa_offset 32
111 ; CHECK-NEXT: .cfi_offset w30, -16
112 ; CHECK-NEXT: adrp x8, lhs
113 ; CHECK-NEXT: ldr q0, [x8, :lo12:lhs]
114 ; CHECK-NEXT: str q0, [sp] // 16-byte Folded Spill
115 ; CHECK-NEXT: bl __fixunstfsi
116 ; CHECK-NEXT: adrp x8, var32
117 ; CHECK-NEXT: str w0, [x8, :lo12:var32]
118 ; CHECK-NEXT: ldr q0, [sp] // 16-byte Folded Reload
119 ; CHECK-NEXT: bl __fixunstfdi
120 ; CHECK-NEXT: adrp x8, var64
121 ; CHECK-NEXT: str x0, [x8, :lo12:var64]
122 ; CHECK-NEXT: ldr x30, [sp, #16] // 8-byte Folded Reload
123 ; CHECK-NEXT: add sp, sp, #32
125 %val = load fp128, ptr @lhs, align 16
127 %val32 = fptoui fp128 %val to i32
128 store i32 %val32, ptr @var32
130 %val64 = fptoui fp128 %val to i64
131 store i64 %val64, ptr @var64
136 define dso_local void @test_sitofp() {
137 ; CHECK-LABEL: test_sitofp:
139 ; CHECK-NEXT: stp x30, x19, [sp, #-16]! // 16-byte Folded Spill
140 ; CHECK-NEXT: .cfi_def_cfa_offset 16
141 ; CHECK-NEXT: .cfi_offset w19, -8
142 ; CHECK-NEXT: .cfi_offset w30, -16
143 ; CHECK-NEXT: adrp x8, var32
144 ; CHECK-NEXT: ldr w0, [x8, :lo12:var32]
145 ; CHECK-NEXT: bl __floatsitf
146 ; CHECK-NEXT: adrp x19, lhs
147 ; CHECK-NEXT: str q0, [x19, :lo12:lhs]
148 ; CHECK-NEXT: adrp x8, var64
149 ; CHECK-NEXT: ldr x0, [x8, :lo12:var64]
150 ; CHECK-NEXT: bl __floatditf
151 ; CHECK-NEXT: str q0, [x19, :lo12:lhs]
152 ; CHECK-NEXT: ldp x30, x19, [sp], #16 // 16-byte Folded Reload
155 %src32 = load i32, ptr @var32
156 %val32 = sitofp i32 %src32 to fp128
157 store volatile fp128 %val32, ptr @lhs
159 %src64 = load i64, ptr @var64
160 %val64 = sitofp i64 %src64 to fp128
161 store volatile fp128 %val64, ptr @lhs
166 define dso_local void @test_uitofp() {
167 ; CHECK-LABEL: test_uitofp:
169 ; CHECK-NEXT: stp x30, x19, [sp, #-16]! // 16-byte Folded Spill
170 ; CHECK-NEXT: .cfi_def_cfa_offset 16
171 ; CHECK-NEXT: .cfi_offset w19, -8
172 ; CHECK-NEXT: .cfi_offset w30, -16
173 ; CHECK-NEXT: adrp x8, var32
174 ; CHECK-NEXT: ldr w0, [x8, :lo12:var32]
175 ; CHECK-NEXT: bl __floatunsitf
176 ; CHECK-NEXT: adrp x19, lhs
177 ; CHECK-NEXT: str q0, [x19, :lo12:lhs]
178 ; CHECK-NEXT: adrp x8, var64
179 ; CHECK-NEXT: ldr x0, [x8, :lo12:var64]
180 ; CHECK-NEXT: bl __floatunditf
181 ; CHECK-NEXT: str q0, [x19, :lo12:lhs]
182 ; CHECK-NEXT: ldp x30, x19, [sp], #16 // 16-byte Folded Reload
185 %src32 = load i32, ptr @var32
186 %val32 = uitofp i32 %src32 to fp128
187 store volatile fp128 %val32, ptr @lhs
189 %src64 = load i64, ptr @var64
190 %val64 = uitofp i64 %src64 to fp128
191 store volatile fp128 %val64, ptr @lhs
196 define dso_local i1 @test_setcc1() {
197 ; CHECK-LABEL: test_setcc1:
199 ; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
200 ; CHECK-NEXT: .cfi_def_cfa_offset 16
201 ; CHECK-NEXT: .cfi_offset w30, -16
202 ; CHECK-NEXT: adrp x8, lhs
203 ; CHECK-NEXT: ldr q0, [x8, :lo12:lhs]
204 ; CHECK-NEXT: adrp x8, rhs
205 ; CHECK-NEXT: ldr q1, [x8, :lo12:rhs]
206 ; CHECK-NEXT: bl __letf2
207 ; CHECK-NEXT: cmp w0, #0
208 ; CHECK-NEXT: cset w0, le
209 ; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
212 %lhs = load fp128, ptr @lhs, align 16
213 %rhs = load fp128, ptr @rhs, align 16
215 ; Technically, everything after the call to __letf2 is redundant, but we'll let
216 ; LLVM have its fun for now.
217 %val = fcmp ole fp128 %lhs, %rhs
222 define dso_local i1 @test_setcc2() {
223 ; CHECK-LABEL: test_setcc2:
225 ; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
226 ; CHECK-NEXT: .cfi_def_cfa_offset 16
227 ; CHECK-NEXT: .cfi_offset w30, -16
228 ; CHECK-NEXT: adrp x8, lhs
229 ; CHECK-NEXT: ldr q0, [x8, :lo12:lhs]
230 ; CHECK-NEXT: adrp x8, rhs
231 ; CHECK-NEXT: ldr q1, [x8, :lo12:rhs]
232 ; CHECK-NEXT: bl __letf2
233 ; CHECK-NEXT: cmp w0, #0
234 ; CHECK-NEXT: cset w0, gt
235 ; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
238 %lhs = load fp128, ptr @lhs, align 16
239 %rhs = load fp128, ptr @rhs, align 16
241 %val = fcmp ugt fp128 %lhs, %rhs
246 define dso_local i1 @test_setcc3() {
247 ; CHECK-LABEL: test_setcc3:
249 ; CHECK-NEXT: sub sp, sp, #48
250 ; CHECK-NEXT: stp x30, x19, [sp, #32] // 16-byte Folded Spill
251 ; CHECK-NEXT: .cfi_def_cfa_offset 48
252 ; CHECK-NEXT: .cfi_offset w19, -8
253 ; CHECK-NEXT: .cfi_offset w30, -16
254 ; CHECK-NEXT: adrp x8, lhs
255 ; CHECK-NEXT: ldr q0, [x8, :lo12:lhs]
256 ; CHECK-NEXT: adrp x8, rhs
257 ; CHECK-NEXT: ldr q1, [x8, :lo12:rhs]
258 ; CHECK-NEXT: stp q1, q0, [sp] // 32-byte Folded Spill
259 ; CHECK-NEXT: bl __eqtf2
260 ; CHECK-NEXT: mov x19, x0
261 ; CHECK-NEXT: ldp q1, q0, [sp] // 32-byte Folded Reload
262 ; CHECK-NEXT: bl __unordtf2
263 ; CHECK-NEXT: cmp w0, #0
264 ; CHECK-NEXT: ccmp w19, #0, #4, eq
265 ; CHECK-NEXT: cset w0, eq
266 ; CHECK-NEXT: ldp x30, x19, [sp, #32] // 16-byte Folded Reload
267 ; CHECK-NEXT: add sp, sp, #48
270 %lhs = load fp128, ptr @lhs, align 16
271 %rhs = load fp128, ptr @rhs, align 16
273 %val = fcmp ueq fp128 %lhs, %rhs
279 define dso_local i32 @test_br_cc() uwtable {
280 ; CHECK-LABEL: test_br_cc:
282 ; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
283 ; CHECK-NEXT: .cfi_def_cfa_offset 16
284 ; CHECK-NEXT: .cfi_offset w30, -16
285 ; CHECK-NEXT: .cfi_remember_state
286 ; CHECK-NEXT: adrp x8, lhs
287 ; CHECK-NEXT: ldr q0, [x8, :lo12:lhs]
288 ; CHECK-NEXT: adrp x8, rhs
289 ; CHECK-NEXT: ldr q1, [x8, :lo12:rhs]
290 ; CHECK-NEXT: bl __lttf2
291 ; CHECK-NEXT: cmp w0, #0
292 ; CHECK-NEXT: b.ge .LBB11_2
293 ; CHECK-NEXT: // %bb.1: // %iftrue
294 ; CHECK-NEXT: mov w0, #42
295 ; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
296 ; CHECK-NEXT: .cfi_def_cfa_offset 0
297 ; CHECK-NEXT: .cfi_restore w30
299 ; CHECK-NEXT: .LBB11_2: // %iffalse
300 ; CHECK-NEXT: .cfi_restore_state
301 ; CHECK-NEXT: mov w0, #29
302 ; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
303 ; CHECK-NEXT: .cfi_def_cfa_offset 0
304 ; CHECK-NEXT: .cfi_restore w30
307 %lhs = load fp128, ptr @lhs, align 16
308 %rhs = load fp128, ptr @rhs, align 16
310 ; olt == !uge, which LLVM optimizes this to.
311 %cond = fcmp olt fp128 %lhs, %rhs
312 br i1 %cond, label %iftrue, label %iffalse
320 define dso_local void @test_select(i1 %cond, fp128 %lhs, fp128 %rhs) {
321 ; CHECK-LABEL: test_select:
323 ; CHECK-NEXT: tst w0, #0x1
324 ; CHECK-NEXT: b.eq .LBB12_2
325 ; CHECK-NEXT: // %bb.1:
326 ; CHECK-NEXT: mov v1.16b, v0.16b
327 ; CHECK-NEXT: .LBB12_2:
328 ; CHECK-NEXT: adrp x8, lhs
329 ; CHECK-NEXT: str q1, [x8, :lo12:lhs]
332 %val = select i1 %cond, fp128 %lhs, fp128 %rhs
333 store fp128 %val, ptr @lhs, align 16
337 @varhalf = dso_local global half 0.0, align 2
338 @varfloat = dso_local global float 0.0, align 4
339 @vardouble = dso_local global double 0.0, align 8
341 define dso_local void @test_round() {
342 ; CHECK-LABEL: test_round:
344 ; CHECK-NEXT: sub sp, sp, #32
345 ; CHECK-NEXT: str x30, [sp, #16] // 8-byte Folded Spill
346 ; CHECK-NEXT: .cfi_def_cfa_offset 32
347 ; CHECK-NEXT: .cfi_offset w30, -16
348 ; CHECK-NEXT: adrp x8, lhs
349 ; CHECK-NEXT: ldr q0, [x8, :lo12:lhs]
350 ; CHECK-NEXT: str q0, [sp] // 16-byte Folded Spill
351 ; CHECK-NEXT: bl __trunctfhf2
352 ; CHECK-NEXT: adrp x8, varhalf
353 ; CHECK-NEXT: str h0, [x8, :lo12:varhalf]
354 ; CHECK-NEXT: ldr q0, [sp] // 16-byte Folded Reload
355 ; CHECK-NEXT: bl __trunctfsf2
356 ; CHECK-NEXT: adrp x8, varfloat
357 ; CHECK-NEXT: str s0, [x8, :lo12:varfloat]
358 ; CHECK-NEXT: ldr q0, [sp] // 16-byte Folded Reload
359 ; CHECK-NEXT: bl __trunctfdf2
360 ; CHECK-NEXT: adrp x8, vardouble
361 ; CHECK-NEXT: str d0, [x8, :lo12:vardouble]
362 ; CHECK-NEXT: ldr x30, [sp, #16] // 8-byte Folded Reload
363 ; CHECK-NEXT: add sp, sp, #32
366 %val = load fp128, ptr @lhs, align 16
368 %half = fptrunc fp128 %val to half
369 store half %half, ptr @varhalf, align 2
371 %float = fptrunc fp128 %val to float
372 store float %float, ptr @varfloat, align 4
374 %double = fptrunc fp128 %val to double
375 store double %double, ptr @vardouble, align 8
380 define dso_local void @test_extend() {
381 ; CHECK-LABEL: test_extend:
383 ; CHECK-NEXT: stp x30, x19, [sp, #-16]! // 16-byte Folded Spill
384 ; CHECK-NEXT: .cfi_def_cfa_offset 16
385 ; CHECK-NEXT: .cfi_offset w19, -8
386 ; CHECK-NEXT: .cfi_offset w30, -16
387 ; CHECK-NEXT: adrp x19, lhs
388 ; CHECK-NEXT: adrp x8, varhalf
389 ; CHECK-NEXT: ldr h0, [x8, :lo12:varhalf]
390 ; CHECK-NEXT: bl __extendhftf2
391 ; CHECK-NEXT: str q0, [x19, :lo12:lhs]
392 ; CHECK-NEXT: adrp x8, varfloat
393 ; CHECK-NEXT: ldr s0, [x8, :lo12:varfloat]
394 ; CHECK-NEXT: bl __extendsftf2
395 ; CHECK-NEXT: str q0, [x19, :lo12:lhs]
396 ; CHECK-NEXT: adrp x8, vardouble
397 ; CHECK-NEXT: ldr d0, [x8, :lo12:vardouble]
398 ; CHECK-NEXT: bl __extenddftf2
399 ; CHECK-NEXT: str q0, [x19, :lo12:lhs]
400 ; CHECK-NEXT: ldp x30, x19, [sp], #16 // 16-byte Folded Reload
403 %val = load fp128, ptr @lhs, align 16
405 %half = load half, ptr @varhalf
406 %fromhalf = fpext half %half to fp128
407 store volatile fp128 %fromhalf, ptr @lhs, align 16
409 %float = load float, ptr @varfloat
410 %fromfloat = fpext float %float to fp128
411 store volatile fp128 %fromfloat, ptr @lhs, align 16
413 %double = load double, ptr @vardouble
414 %fromdouble = fpext double %double to fp128
415 store volatile fp128 %fromdouble, ptr @lhs, align 16
420 define fp128 @test_neg(fp128 %in) {
421 ; CHECK-LABEL: test_neg:
423 ; CHECK-NEXT: str q0, [sp, #-16]!
424 ; CHECK-NEXT: .cfi_def_cfa_offset 16
425 ; CHECK-NEXT: ldrb w8, [sp, #15]
426 ; CHECK-NEXT: eor w8, w8, #0x80
427 ; CHECK-NEXT: strb w8, [sp, #15]
428 ; CHECK-NEXT: ldr q0, [sp], #16
431 ;; We convert this to fneg, and target-independent code expands it with
432 ;; integer operations.
433 %ret = fsub fp128 0xL00000000000000008000000000000000, %in