1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 --mattr=+f,-d < %s | FileCheck %s --check-prefix=LA32F
3 ; RUN: llc --mtriple=loongarch32 --mattr=+d < %s | FileCheck %s --check-prefix=LA32D
4 ; RUN: llc --mtriple=loongarch64 --mattr=+f,-d < %s | FileCheck %s --check-prefix=LA64F
5 ; RUN: llc --mtriple=loongarch64 --mattr=+d < %s | FileCheck %s --check-prefix=LA64D
7 define void @fp_trunc(ptr %a, double %b) nounwind {
8 ; LA32F-LABEL: fp_trunc:
10 ; LA32F-NEXT: addi.w $sp, $sp, -16
11 ; LA32F-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
12 ; LA32F-NEXT: st.w $fp, $sp, 8 # 4-byte Folded Spill
13 ; LA32F-NEXT: move $fp, $a0
14 ; LA32F-NEXT: move $a0, $a1
15 ; LA32F-NEXT: move $a1, $a2
16 ; LA32F-NEXT: bl %plt(__truncdfsf2)
17 ; LA32F-NEXT: fst.s $fa0, $fp, 0
18 ; LA32F-NEXT: ld.w $fp, $sp, 8 # 4-byte Folded Reload
19 ; LA32F-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
20 ; LA32F-NEXT: addi.w $sp, $sp, 16
23 ; LA32D-LABEL: fp_trunc:
25 ; LA32D-NEXT: fcvt.s.d $fa0, $fa0
26 ; LA32D-NEXT: fst.s $fa0, $a0, 0
29 ; LA64F-LABEL: fp_trunc:
31 ; LA64F-NEXT: addi.d $sp, $sp, -16
32 ; LA64F-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
33 ; LA64F-NEXT: st.d $fp, $sp, 0 # 8-byte Folded Spill
34 ; LA64F-NEXT: move $fp, $a0
35 ; LA64F-NEXT: move $a0, $a1
36 ; LA64F-NEXT: bl %plt(__truncdfsf2)
37 ; LA64F-NEXT: fst.s $fa0, $fp, 0
38 ; LA64F-NEXT: ld.d $fp, $sp, 0 # 8-byte Folded Reload
39 ; LA64F-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
40 ; LA64F-NEXT: addi.d $sp, $sp, 16
43 ; LA64D-LABEL: fp_trunc:
45 ; LA64D-NEXT: fcvt.s.d $fa0, $fa0
46 ; LA64D-NEXT: fst.s $fa0, $a0, 0
48 %1 = fptrunc double %b to float
49 store float %1, ptr %a, align 4