1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 --mattr=+d < %s | FileCheck %s --check-prefix=LA32
3 ; RUN: llc --mtriple=loongarch64 --mattr=+d < %s | FileCheck %s --check-prefix=LA64
5 ;; TODO: Add more test cases after ABI implementation for ilp32f and lp64f.
7 declare float @llvm.sin.f32(float)
8 declare float @llvm.cos.f32(float)
9 declare float @llvm.pow.f32(float, float)
10 declare double @llvm.sin.f64(double)
11 declare double @llvm.cos.f64(double)
12 declare double @llvm.pow.f64(double, double)
14 define float @sin_f32(float %a) nounwind {
15 ; LA32-LABEL: sin_f32:
17 ; LA32-NEXT: b %plt(sinf)
19 ; LA64-LABEL: sin_f32:
21 ; LA64-NEXT: b %plt(sinf)
22 %1 = call float @llvm.sin.f32(float %a)
26 define float @cos_f32(float %a) nounwind {
27 ; LA32-LABEL: cos_f32:
29 ; LA32-NEXT: b %plt(cosf)
31 ; LA64-LABEL: cos_f32:
33 ; LA64-NEXT: b %plt(cosf)
34 %1 = call float @llvm.cos.f32(float %a)
38 define float @sincos_f32(float %a) nounwind {
39 ; LA32-LABEL: sincos_f32:
41 ; LA32-NEXT: addi.w $sp, $sp, -32
42 ; LA32-NEXT: st.w $ra, $sp, 28 # 4-byte Folded Spill
43 ; LA32-NEXT: fst.d $fs0, $sp, 16 # 8-byte Folded Spill
44 ; LA32-NEXT: fst.d $fs1, $sp, 8 # 8-byte Folded Spill
45 ; LA32-NEXT: fmov.s $fs0, $fa0
46 ; LA32-NEXT: bl %plt(sinf)
47 ; LA32-NEXT: fmov.s $fs1, $fa0
48 ; LA32-NEXT: fmov.s $fa0, $fs0
49 ; LA32-NEXT: bl %plt(cosf)
50 ; LA32-NEXT: fadd.s $fa0, $fs1, $fa0
51 ; LA32-NEXT: fld.d $fs1, $sp, 8 # 8-byte Folded Reload
52 ; LA32-NEXT: fld.d $fs0, $sp, 16 # 8-byte Folded Reload
53 ; LA32-NEXT: ld.w $ra, $sp, 28 # 4-byte Folded Reload
54 ; LA32-NEXT: addi.w $sp, $sp, 32
57 ; LA64-LABEL: sincos_f32:
59 ; LA64-NEXT: addi.d $sp, $sp, -32
60 ; LA64-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
61 ; LA64-NEXT: fst.d $fs0, $sp, 16 # 8-byte Folded Spill
62 ; LA64-NEXT: fst.d $fs1, $sp, 8 # 8-byte Folded Spill
63 ; LA64-NEXT: fmov.s $fs0, $fa0
64 ; LA64-NEXT: bl %plt(sinf)
65 ; LA64-NEXT: fmov.s $fs1, $fa0
66 ; LA64-NEXT: fmov.s $fa0, $fs0
67 ; LA64-NEXT: bl %plt(cosf)
68 ; LA64-NEXT: fadd.s $fa0, $fs1, $fa0
69 ; LA64-NEXT: fld.d $fs1, $sp, 8 # 8-byte Folded Reload
70 ; LA64-NEXT: fld.d $fs0, $sp, 16 # 8-byte Folded Reload
71 ; LA64-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
72 ; LA64-NEXT: addi.d $sp, $sp, 32
74 %1 = call float @llvm.sin.f32(float %a)
75 %2 = call float @llvm.cos.f32(float %a)
76 %3 = fadd float %1, %2
80 define float @pow_f32(float %a, float %b) nounwind {
81 ; LA32-LABEL: pow_f32:
83 ; LA32-NEXT: b %plt(powf)
85 ; LA64-LABEL: pow_f32:
87 ; LA64-NEXT: b %plt(powf)
88 %1 = call float @llvm.pow.f32(float %a, float %b)
92 define float @frem_f32(float %a, float %b) nounwind {
93 ; LA32-LABEL: frem_f32:
95 ; LA32-NEXT: b %plt(fmodf)
97 ; LA64-LABEL: frem_f32:
99 ; LA64-NEXT: b %plt(fmodf)
100 %1 = frem float %a, %b
104 define double @sin_f64(double %a) nounwind {
105 ; LA32-LABEL: sin_f64:
107 ; LA32-NEXT: b %plt(sin)
109 ; LA64-LABEL: sin_f64:
111 ; LA64-NEXT: b %plt(sin)
112 %1 = call double @llvm.sin.f64(double %a)
116 define double @cos_f64(double %a) nounwind {
117 ; LA32-LABEL: cos_f64:
119 ; LA32-NEXT: b %plt(cos)
121 ; LA64-LABEL: cos_f64:
123 ; LA64-NEXT: b %plt(cos)
124 %1 = call double @llvm.cos.f64(double %a)
128 define double @sincos_f64(double %a) nounwind {
129 ; LA32-LABEL: sincos_f64:
131 ; LA32-NEXT: addi.w $sp, $sp, -32
132 ; LA32-NEXT: st.w $ra, $sp, 28 # 4-byte Folded Spill
133 ; LA32-NEXT: fst.d $fs0, $sp, 16 # 8-byte Folded Spill
134 ; LA32-NEXT: fst.d $fs1, $sp, 8 # 8-byte Folded Spill
135 ; LA32-NEXT: fmov.d $fs0, $fa0
136 ; LA32-NEXT: bl %plt(sin)
137 ; LA32-NEXT: fmov.d $fs1, $fa0
138 ; LA32-NEXT: fmov.d $fa0, $fs0
139 ; LA32-NEXT: bl %plt(cos)
140 ; LA32-NEXT: fadd.d $fa0, $fs1, $fa0
141 ; LA32-NEXT: fld.d $fs1, $sp, 8 # 8-byte Folded Reload
142 ; LA32-NEXT: fld.d $fs0, $sp, 16 # 8-byte Folded Reload
143 ; LA32-NEXT: ld.w $ra, $sp, 28 # 4-byte Folded Reload
144 ; LA32-NEXT: addi.w $sp, $sp, 32
147 ; LA64-LABEL: sincos_f64:
149 ; LA64-NEXT: addi.d $sp, $sp, -32
150 ; LA64-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
151 ; LA64-NEXT: fst.d $fs0, $sp, 16 # 8-byte Folded Spill
152 ; LA64-NEXT: fst.d $fs1, $sp, 8 # 8-byte Folded Spill
153 ; LA64-NEXT: fmov.d $fs0, $fa0
154 ; LA64-NEXT: bl %plt(sin)
155 ; LA64-NEXT: fmov.d $fs1, $fa0
156 ; LA64-NEXT: fmov.d $fa0, $fs0
157 ; LA64-NEXT: bl %plt(cos)
158 ; LA64-NEXT: fadd.d $fa0, $fs1, $fa0
159 ; LA64-NEXT: fld.d $fs1, $sp, 8 # 8-byte Folded Reload
160 ; LA64-NEXT: fld.d $fs0, $sp, 16 # 8-byte Folded Reload
161 ; LA64-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
162 ; LA64-NEXT: addi.d $sp, $sp, 32
164 %1 = call double @llvm.sin.f64(double %a)
165 %2 = call double @llvm.cos.f64(double %a)
166 %3 = fadd double %1, %2
170 define double @pow_f64(double %a, double %b) nounwind {
171 ; LA32-LABEL: pow_f64:
173 ; LA32-NEXT: b %plt(pow)
175 ; LA64-LABEL: pow_f64:
177 ; LA64-NEXT: b %plt(pow)
178 %1 = call double @llvm.pow.f64(double %a, double %b)
182 define double @frem_f64(double %a, double %b) nounwind {
183 ; LA32-LABEL: frem_f64:
185 ; LA32-NEXT: b %plt(fmod)
187 ; LA64-LABEL: frem_f64:
189 ; LA64-NEXT: b %plt(fmod)
190 %1 = frem double %a, %b