1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 < %s | FileCheck %s --check-prefix=LA32
3 ; RUN: llc --mtriple=loongarch64 < %s | FileCheck %s --check-prefix=LA64
5 define i32 @fptosi_i32_fp128(fp128 %X) nounwind {
6 ; LA32-LABEL: fptosi_i32_fp128:
8 ; LA32-NEXT: addi.w $sp, $sp, -32
9 ; LA32-NEXT: st.w $ra, $sp, 28 # 4-byte Folded Spill
10 ; LA32-NEXT: ld.w $a1, $a0, 12
11 ; LA32-NEXT: st.w $a1, $sp, 20
12 ; LA32-NEXT: ld.w $a1, $a0, 8
13 ; LA32-NEXT: st.w $a1, $sp, 16
14 ; LA32-NEXT: ld.w $a1, $a0, 4
15 ; LA32-NEXT: st.w $a1, $sp, 12
16 ; LA32-NEXT: ld.w $a0, $a0, 0
17 ; LA32-NEXT: st.w $a0, $sp, 8
18 ; LA32-NEXT: addi.w $a0, $sp, 8
19 ; LA32-NEXT: bl %plt(__fixtfsi)
20 ; LA32-NEXT: ld.w $ra, $sp, 28 # 4-byte Folded Reload
21 ; LA32-NEXT: addi.w $sp, $sp, 32
24 ; LA64-LABEL: fptosi_i32_fp128:
26 ; LA64-NEXT: addi.d $sp, $sp, -16
27 ; LA64-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
28 ; LA64-NEXT: bl %plt(__fixtfsi)
29 ; LA64-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
30 ; LA64-NEXT: addi.d $sp, $sp, 16
32 %tmp = fptosi fp128 %X to i32
36 define i32 @fptosi_i32_double(double %X) nounwind {
37 ; LA32-LABEL: fptosi_i32_double:
39 ; LA32-NEXT: addi.w $sp, $sp, -16
40 ; LA32-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
41 ; LA32-NEXT: bl %plt(__fixdfsi)
42 ; LA32-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
43 ; LA32-NEXT: addi.w $sp, $sp, 16
46 ; LA64-LABEL: fptosi_i32_double:
48 ; LA64-NEXT: addi.d $sp, $sp, -16
49 ; LA64-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
50 ; LA64-NEXT: bl %plt(__fixdfsi)
51 ; LA64-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
52 ; LA64-NEXT: addi.d $sp, $sp, 16
54 %tmp = fptosi double %X to i32
58 define i32 @fptosi_i32_float(float %X) nounwind {
59 ; LA32-LABEL: fptosi_i32_float:
61 ; LA32-NEXT: addi.w $sp, $sp, -16
62 ; LA32-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
63 ; LA32-NEXT: bl %plt(__fixsfsi)
64 ; LA32-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
65 ; LA32-NEXT: addi.w $sp, $sp, 16
68 ; LA64-LABEL: fptosi_i32_float:
70 ; LA64-NEXT: addi.d $sp, $sp, -16
71 ; LA64-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
72 ; LA64-NEXT: bstrpick.d $a0, $a0, 31, 0
73 ; LA64-NEXT: bl %plt(__fixsfsi)
74 ; LA64-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
75 ; LA64-NEXT: addi.d $sp, $sp, 16
77 %tmp = fptosi float %X to i32
81 define i64 @fptosi_i64_fp128(fp128 %X) nounwind {
82 ; LA32-LABEL: fptosi_i64_fp128:
84 ; LA32-NEXT: addi.w $sp, $sp, -32
85 ; LA32-NEXT: st.w $ra, $sp, 28 # 4-byte Folded Spill
86 ; LA32-NEXT: ld.w $a1, $a0, 12
87 ; LA32-NEXT: st.w $a1, $sp, 12
88 ; LA32-NEXT: ld.w $a1, $a0, 8
89 ; LA32-NEXT: st.w $a1, $sp, 8
90 ; LA32-NEXT: ld.w $a1, $a0, 4
91 ; LA32-NEXT: st.w $a1, $sp, 4
92 ; LA32-NEXT: ld.w $a0, $a0, 0
93 ; LA32-NEXT: st.w $a0, $sp, 0
94 ; LA32-NEXT: addi.w $a0, $sp, 0
95 ; LA32-NEXT: bl %plt(__fixtfdi)
96 ; LA32-NEXT: ld.w $ra, $sp, 28 # 4-byte Folded Reload
97 ; LA32-NEXT: addi.w $sp, $sp, 32
100 ; LA64-LABEL: fptosi_i64_fp128:
102 ; LA64-NEXT: addi.d $sp, $sp, -16
103 ; LA64-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
104 ; LA64-NEXT: bl %plt(__fixtfdi)
105 ; LA64-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
106 ; LA64-NEXT: addi.d $sp, $sp, 16
108 %tmp = fptosi fp128 %X to i64
112 define i64 @fptosi_i64_double(double %X) nounwind {
113 ; LA32-LABEL: fptosi_i64_double:
115 ; LA32-NEXT: addi.w $sp, $sp, -16
116 ; LA32-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
117 ; LA32-NEXT: bl %plt(__fixdfdi)
118 ; LA32-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
119 ; LA32-NEXT: addi.w $sp, $sp, 16
122 ; LA64-LABEL: fptosi_i64_double:
124 ; LA64-NEXT: addi.d $sp, $sp, -16
125 ; LA64-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
126 ; LA64-NEXT: bl %plt(__fixdfdi)
127 ; LA64-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
128 ; LA64-NEXT: addi.d $sp, $sp, 16
130 %tmp = fptosi double %X to i64
134 define i64 @fptosi_i64_float(float %X) nounwind {
135 ; LA32-LABEL: fptosi_i64_float:
137 ; LA32-NEXT: addi.w $sp, $sp, -16
138 ; LA32-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
139 ; LA32-NEXT: bl %plt(__fixsfdi)
140 ; LA32-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
141 ; LA32-NEXT: addi.w $sp, $sp, 16
144 ; LA64-LABEL: fptosi_i64_float:
146 ; LA64-NEXT: addi.d $sp, $sp, -16
147 ; LA64-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
148 ; LA64-NEXT: bstrpick.d $a0, $a0, 31, 0
149 ; LA64-NEXT: bl %plt(__fixsfdi)
150 ; LA64-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
151 ; LA64-NEXT: addi.d $sp, $sp, 16
153 %tmp = fptosi float %X to i64