• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 | 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
5
6
7; CHECK-LABEL: f128_ops:
8; CHECK:      ldd
9; CHECK:      ldd
10; CHECK:      ldd
11; CHECK:      ldd
12; HARD:       faddq [[R0:.+]],  [[R1:.+]],  [[R2:.+]]
13; HARD:       fsubq [[R2]], [[R3:.+]], [[R4:.+]]
14; HARD:       fmulq [[R4]], [[R5:.+]], [[R6:.+]]
15; HARD:       fdivq [[R6]], [[R2]]
16; SOFT:       call _Q_add
17; SOFT:       call _Q_sub
18; SOFT:       call _Q_mul
19; SOFT:       call _Q_div
20; CHECK:      std
21; CHECK:      std
22
23define void @f128_ops(fp128* noalias sret %scalar.result, fp128* byval %a, fp128* byval %b, fp128* byval %c, fp128* byval %d) {
24entry:
25  %0 = load fp128, fp128* %a, align 8
26  %1 = load fp128, fp128* %b, align 8
27  %2 = load fp128, fp128* %c, align 8
28  %3 = load fp128, fp128* %d, align 8
29  %4 = fadd fp128 %0, %1
30  %5 = fsub fp128 %4, %2
31  %6 = fmul fp128 %5, %3
32  %7 = fdiv fp128 %6, %4
33  store fp128 %7, fp128* %scalar.result, align 8
34  ret void
35}
36
37; CHECK-LABEL: f128_spill:
38; CHECK:       std %f{{.+}}, [%[[S0:.+]]]
39; CHECK:       std %f{{.+}}, [%[[S1:.+]]]
40; CHECK-DAG:   ldd [%[[S0]]], %f{{.+}}
41; CHECK-DAG:   ldd [%[[S1]]], %f{{.+}}
42; CHECK:       jmp {{%[oi]7}}+12
43
44define void @f128_spill(fp128* noalias sret %scalar.result, fp128* byval %a) {
45entry:
46  %0 = load fp128, fp128* %a, align 8
47  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}"()
48  store fp128 %0, fp128* %scalar.result, align 8
49  ret void
50}
51
52; CHECK-LABEL: f128_compare:
53; HARD:       fcmpq
54; HARD-NEXT:  nop
55; SOFT:       _Q_cmp
56
57define i32 @f128_compare(fp128* byval %f0, fp128* byval %f1, i32 %a, i32 %b) {
58entry:
59   %0 = load fp128, fp128* %f0, align 8
60   %1 = load fp128, fp128* %f1, align 8
61   %cond = fcmp ult fp128 %0, %1
62   %ret = select i1 %cond, i32 %a, i32 %b
63   ret i32 %ret
64}
65
66; CHECK-LABEL: f128_compare2:
67; HARD:        fcmpq
68; HARD:        fb{{ule|g}}
69; SOFT:       _Q_cmp
70; SOFT:       cmp
71
72define i32 @f128_compare2() {
73entry:
74  %0 = fcmp ogt fp128 undef, 0xL00000000000000000000000000000000
75  br i1 %0, label %"5", label %"7"
76
77"5":                                              ; preds = %entry
78  ret i32 0
79
80"7":                                              ; preds = %entry
81  ret i32 1
82}
83
84
85; CHECK-LABEL: f128_abs:
86; CHECK:       ldd [%o0], %f0
87; CHECK:       ldd [%o0+8], %f2
88; BE:          fabss %f0, %f0
89; EL:          fabss %f3, %f3
90
91define void @f128_abs(fp128* noalias sret %scalar.result, fp128* byval %a) {
92entry:
93  %0 = load fp128, fp128* %a, align 8
94  %1 = tail call fp128 @llvm.fabs.f128(fp128 %0)
95  store fp128 %1, fp128* %scalar.result, align 8
96  ret void
97}
98
99declare fp128 @llvm.fabs.f128(fp128) nounwind readonly
100
101; CHECK-LABEL: int_to_f128:
102; HARD:       fitoq
103; SOFT:       _Q_itoq
104
105define void @int_to_f128(fp128* noalias sret %scalar.result, i32 %i) {
106entry:
107  %0 = sitofp i32 %i to fp128
108  store fp128 %0, fp128* %scalar.result, align 8
109  ret void
110}
111
112; CHECK-LABEL: fp128_unaligned:
113; CHECK:       ldub
114; HARD:        faddq
115; SOFT:       call _Q_add
116; CHECK:       stb
117; CHECK:       ret
118
119define void @fp128_unaligned(fp128* %a, fp128* %b, fp128* %c) {
120entry:
121  %0 = load fp128, fp128* %a, align 1
122  %1 = load fp128, fp128* %b, align 1
123  %2 = fadd fp128 %0, %1
124  store fp128 %2, fp128* %c, align 1
125  ret void
126}
127
128; CHECK-LABEL: uint_to_f128:
129; HARD:       fdtoq
130; SOFT:       _Q_utoq
131
132define void @uint_to_f128(fp128* noalias sret %scalar.result, i32 %i) {
133entry:
134  %0 = uitofp i32 %i to fp128
135  store fp128 %0, fp128* %scalar.result, align 8
136  ret void
137}
138
139; CHECK-LABEL: f128_to_i32:
140; HARD:       fqtoi
141; HARD:       fqtoi
142; SOFT:       call _Q_qtou
143; SOFT:       call _Q_qtoi
144
145
146define i32 @f128_to_i32(fp128* %a, fp128* %b) {
147entry:
148  %0 = load fp128, fp128* %a, align 8
149  %1 = load fp128, fp128* %b, align 8
150  %2 = fptoui fp128 %0 to i32
151  %3 = fptosi fp128 %1 to i32
152  %4 = add i32 %2, %3
153  ret i32 %4
154}
155
156; CHECK-LABEL:   test_itoq_qtoi
157; HARD-DAG:      call _Q_lltoq
158; HARD-DAG:      call _Q_qtoll
159; HARD-DAG:      fitoq
160; HARD-DAG:      fqtoi
161; SOFT-DAG:      call _Q_lltoq
162; SOFT-DAG:      call _Q_qtoll
163; SOFT-DAG:      call _Q_itoq
164; SOFT-DAG:      call _Q_qtoi
165
166define void @test_itoq_qtoi(i64 %a, i32 %b, fp128* %c, fp128* %d, i64* %ptr0, fp128* %ptr1) {
167entry:
168  %0 = sitofp i64 %a to fp128
169  store  fp128 %0, fp128* %ptr1, align 8
170  %cval = load fp128, fp128* %c, align 8
171  %1 = fptosi fp128 %cval to i64
172  store  i64 %1, i64* %ptr0, align 8
173  %2 = sitofp i32 %b to fp128
174  store  fp128 %2, fp128* %ptr1, align 8
175  %dval = load fp128, fp128* %d, align 8
176  %3 = fptosi fp128 %dval to i32
177  %4 = bitcast i64* %ptr0 to i32*
178  store  i32 %3, i32* %4, align 8
179  ret void
180}
181
182; CHECK-LABEL:   test_utoq_qtou:
183; CHECK-DAG:     call _Q_ulltoq
184; CHECK-DAG:     call _Q_qtoull
185; HARD-DAG:      fdtoq
186; HARD-DAG:      fqtoi
187; SOFT-DAG:      call _Q_utoq
188; SOFT-DAG:      call _Q_qtou
189
190define void @test_utoq_qtou(i64 %a, i32 %b, fp128* %c, fp128* %d, i64* %ptr0, fp128* %ptr1) {
191entry:
192  %0 = uitofp i64 %a to fp128
193  store  fp128 %0, fp128* %ptr1, align 8
194  %cval = load fp128, fp128* %c, align 8
195  %1 = fptoui fp128 %cval to i64
196  store  i64 %1, i64* %ptr0, align 8
197  %2 = uitofp i32 %b to fp128
198  store  fp128 %2, fp128* %ptr1, align 8
199  %dval = load fp128, fp128* %d, align 8
200  %3 = fptoui fp128 %dval to i32
201  %4 = bitcast i64* %ptr0 to i32*
202  store  i32 %3, i32* %4, align 8
203  ret void
204}
205
206; CHECK-LABEL: f128_neg:
207; CHECK:       ldd [%o0], %f0
208; CHECK:       ldd [%o0+8], %f2
209; BE:          fnegs %f0, %f0
210; EL:          fnegs %f3, %f3
211
212define void @f128_neg(fp128* noalias sret %scalar.result, fp128* byval %a) {
213entry:
214  %0 = load fp128, fp128* %a, align 8
215  %1 = fsub fp128 0xL00000000000000008000000000000000, %0
216  store fp128 %1, fp128* %scalar.result, align 8
217  ret void
218}
219