1 ; RUN: llc < %s -march=sparc -mattr=hard-quad-float | FileCheck %s --check-prefix=CHECK --check-prefix=HARD --check-prefix=BE
2 ; RUN: llc < %s -march=sparcel -mattr=hard-quad-float | FileCheck %s --check-prefix=CHECK --check-prefix=HARD --check-prefix=EL
3 ; RUN: llc < %s -march=sparc -mattr=-hard-quad-float -verify-machineinstrs | FileCheck %s --check-prefix=CHECK --check-prefix=SOFT --check-prefix=BE
4 ; RUN: llc < %s -march=sparcel -mattr=-hard-quad-float | FileCheck %s --check-prefix=CHECK --check-prefix=SOFT --check-prefix=EL
6 ; CHECK-LABEL: f128_ops:
11 ; HARD: faddq [[R0:.+]], [[R1:.+]], [[R2:.+]]
12 ; HARD: fsubq [[R2]], [[R3:.+]], [[R4:.+]]
13 ; HARD: fmulq [[R4]], [[R5:.+]], [[R6:.+]]
14 ; HARD: fdivq [[R6]], [[R2]]
26 define void @f128_ops(ptr noalias sret(fp128) %scalar.result, ptr byval(fp128) %a, ptr byval(fp128) %b, ptr byval(fp128) %c, ptr byval(fp128) %d) {
28 %0 = load fp128, ptr %a, align 8
29 %1 = load fp128, ptr %b, align 8
30 %2 = load fp128, ptr %c, align 8
31 %3 = load fp128, ptr %d, align 8
32 %4 = fadd fp128 %0, %1
33 %5 = fsub fp128 %4, %2
34 %6 = fmul fp128 %5, %3
35 %7 = fdiv fp128 %6, %4
36 store fp128 %7, ptr %scalar.result, align 8
40 ; CHECK-LABEL: f128_spill:
41 ; CHECK: std %f{{.+}}, [%[[S0:.+]]]
42 ; CHECK: std %f{{.+}}, [%[[S1:.+]]]
43 ; CHECK-DAG: ldd [%[[S0]]], %f{{.+}}
44 ; CHECK-DAG: ldd [%[[S1]]], %f{{.+}}
45 ; CHECK: jmp {{%[oi]7}}+12
47 define void @f128_spill(ptr noalias sret(fp128) %scalar.result, ptr byval(fp128) %a) {
49 %0 = load fp128, ptr %a, align 8
50 call void asm sideeffect "", "~{f0},~{f1},~{f2},~{f3},~{f4},~{f5},~{f6},~{f7},~{f8},~{f9},~{f10},~{f11},~{f12},~{f13},~{f14},~{f15},~{f16},~{f17},~{f18},~{f19},~{f20},~{f21},~{f22},~{f23},~{f24},~{f25},~{f26},~{f27},~{f28},~{f29},~{f30},~{f31}"()
51 store fp128 %0, ptr %scalar.result, align 8
55 ; CHECK-LABEL: f128_spill_large:
58 ; CHECK-NEXT: add %g1, %sp, %g1
59 ; CHECK-NEXT: std %f{{.+}}, [%g1]
61 ; CHECK-NEXT: add %g1, %sp, %g1
62 ; CHECK-NEXT: std %f{{.+}}, [%g1+8]
64 ; CHECK-NEXT: add %g1, %sp, %g1
65 ; CHECK-NEXT: ldd [%g1], %f{{.+}}
67 ; CHECK-NEXT: add %g1, %sp, %g1
68 ; CHECK-NEXT: ldd [%g1+8], %f{{.+}}
70 define void @f128_spill_large(ptr noalias sret(<251 x fp128>) %scalar.result, ptr byval(<251 x fp128>) %a) {
72 %0 = load <251 x fp128>, ptr %a, align 8
73 call void asm sideeffect "", "~{f0},~{f1},~{f2},~{f3},~{f4},~{f5},~{f6},~{f7},~{f8},~{f9},~{f10},~{f11},~{f12},~{f13},~{f14},~{f15},~{f16},~{f17},~{f18},~{f19},~{f20},~{f21},~{f22},~{f23},~{f24},~{f25},~{f26},~{f27},~{f28},~{f29},~{f30},~{f31}"()
74 store <251 x fp128> %0, ptr %scalar.result, align 8
78 ; CHECK-LABEL: f128_compare:
83 define i32 @f128_compare(ptr byval(fp128) %f0, ptr byval(fp128) %f1, i32 %a, i32 %b) {
85 %0 = load fp128, ptr %f0, align 8
86 %1 = load fp128, ptr %f1, align 8
87 %cond = fcmp ult fp128 %0, %1
88 %ret = select i1 %cond, i32 %a, i32 %b
92 ; CHECK-LABEL: f128_compare2:
98 define i32 @f128_compare2(ptr byval(fp128) %f0) {
100 %0 = load fp128, ptr %f0, align 8
101 %1 = fcmp ogt fp128 %0, 0xL00000000000000000000000000000000
102 br i1 %1, label %"5", label %"7"
104 "5": ; preds = %entry
107 "7": ; preds = %entry
112 ; CHECK-LABEL: f128_abs:
113 ; CHECK: ldd [%o0], %f0
114 ; CHECK: ldd [%o0+8], %f2
118 define void @f128_abs(ptr noalias sret(fp128) %scalar.result, ptr byval(fp128) %a) {
120 %0 = load fp128, ptr %a, align 8
121 %1 = tail call fp128 @llvm.fabs.f128(fp128 %0)
122 store fp128 %1, ptr %scalar.result, align 8
126 declare fp128 @llvm.fabs.f128(fp128) nounwind readonly
128 ; CHECK-LABEL: int_to_f128:
133 define void @int_to_f128(ptr noalias sret(fp128) %scalar.result, i32 %i) {
135 %0 = sitofp i32 %i to fp128
136 store fp128 %0, ptr %scalar.result, align 8
140 ; CHECK-LABEL: fp128_unaligned:
148 define void @fp128_unaligned(ptr %a, ptr %b, ptr %c) {
150 %0 = load fp128, ptr %a, align 1
151 %1 = load fp128, ptr %b, align 1
152 %2 = fadd fp128 %0, %1
153 store fp128 %2, ptr %c, align 1
157 ; CHECK-LABEL: uint_to_f128:
162 define void @uint_to_f128(ptr noalias sret(fp128) %scalar.result, i32 %i) {
164 %0 = uitofp i32 %i to fp128
165 store fp128 %0, ptr %scalar.result, align 8
169 ; CHECK-LABEL: f128_to_i32:
176 define i32 @f128_to_i32(ptr %a, ptr %b) {
178 %0 = load fp128, ptr %a, align 8
179 %1 = load fp128, ptr %b, align 8
180 %2 = fptoui fp128 %0 to i32
181 %3 = fptosi fp128 %1 to i32
186 ; CHECK-LABEL: test_itoq_qtoi
187 ; HARD-DAG: call _Q_lltoq
188 ; HARD-DAG: call _Q_qtoll
191 ; SOFT-DAG: call _Q_lltoq
193 ; SOFT-DAG: call _Q_qtoll
194 ; SOFT-DAG: call _Q_itoq
196 ; SOFT-DAG: call _Q_qtoi
198 define void @test_itoq_qtoi(i64 %a, i32 %b, ptr %c, ptr %d, ptr %ptr0, ptr %ptr1) {
200 %0 = sitofp i64 %a to fp128
201 store fp128 %0, ptr %ptr1, align 8
202 %cval = load fp128, ptr %c, align 8
203 %1 = fptosi fp128 %cval to i64
204 store i64 %1, ptr %ptr0, align 8
205 %2 = sitofp i32 %b to fp128
206 store fp128 %2, ptr %ptr1, align 8
207 %dval = load fp128, ptr %d, align 8
208 %3 = fptosi fp128 %dval to i32
209 %4 = bitcast ptr %ptr0 to ptr
210 store i32 %3, ptr %4, align 8
214 ; CHECK-LABEL: test_utoq_qtou:
215 ; CHECK-DAG: call _Q_ulltoq
216 ; CHECK-DAG: call _Q_qtoull
219 ; SOFT-DAG: call _Q_utoq
221 ; SOFT-DAG: call _Q_qtou
223 define void @test_utoq_qtou(i64 %a, i32 %b, ptr %c, ptr %d, ptr %ptr0, ptr %ptr1) {
225 %0 = uitofp i64 %a to fp128
226 store fp128 %0, ptr %ptr1, align 8
227 %cval = load fp128, ptr %c, align 8
228 %1 = fptoui fp128 %cval to i64
229 store i64 %1, ptr %ptr0, align 8
230 %2 = uitofp i32 %b to fp128
231 store fp128 %2, ptr %ptr1, align 8
232 %dval = load fp128, ptr %d, align 8
233 %3 = fptoui fp128 %dval to i32
234 %4 = bitcast ptr %ptr0 to ptr
235 store i32 %3, ptr %4, align 8
239 ; CHECK-LABEL: f128_neg:
240 ; CHECK: ldd [%o0], %f0
241 ; CHECK: ldd [%o0+8], %f2
245 define void @f128_neg(ptr noalias sret(fp128) %scalar.result, ptr byval(fp128) %a) {
247 %0 = load fp128, ptr %a, align 8
248 %1 = fsub fp128 0xL00000000000000008000000000000000, %0
249 store fp128 %1, ptr %scalar.result, align 8