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 declare float @llvm.sqrt.f32(float)
8 declare double @llvm.sqrt.f64(double)
10 define float @fsqrt_f32(float %a) nounwind {
11 ; LA32F-LABEL: fsqrt_f32:
13 ; LA32F-NEXT: fsqrt.s $fa0, $fa0
16 ; LA32D-LABEL: fsqrt_f32:
18 ; LA32D-NEXT: fsqrt.s $fa0, $fa0
21 ; LA64F-LABEL: fsqrt_f32:
23 ; LA64F-NEXT: fsqrt.s $fa0, $fa0
26 ; LA64D-LABEL: fsqrt_f32:
28 ; LA64D-NEXT: fsqrt.s $fa0, $fa0
30 %1 = call float @llvm.sqrt.f32(float %a)
34 define double @fsqrt_f64(double %a) nounwind {
35 ; LA32F-LABEL: fsqrt_f64:
37 ; LA32F-NEXT: addi.w $sp, $sp, -16
38 ; LA32F-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
39 ; LA32F-NEXT: bl %plt(sqrt)
40 ; LA32F-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
41 ; LA32F-NEXT: addi.w $sp, $sp, 16
44 ; LA32D-LABEL: fsqrt_f64:
46 ; LA32D-NEXT: fsqrt.d $fa0, $fa0
49 ; LA64F-LABEL: fsqrt_f64:
51 ; LA64F-NEXT: addi.d $sp, $sp, -16
52 ; LA64F-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
53 ; LA64F-NEXT: bl %plt(sqrt)
54 ; LA64F-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
55 ; LA64F-NEXT: addi.d $sp, $sp, 16
58 ; LA64D-LABEL: fsqrt_f64:
60 ; LA64D-NEXT: fsqrt.d $fa0, $fa0
62 %1 = call double @llvm.sqrt.f64(double %a)
66 define float @frsqrt_f32(float %a) nounwind {
67 ; LA32F-LABEL: frsqrt_f32:
69 ; LA32F-NEXT: frsqrt.s $fa0, $fa0
72 ; LA32D-LABEL: frsqrt_f32:
74 ; LA32D-NEXT: frsqrt.s $fa0, $fa0
77 ; LA64F-LABEL: frsqrt_f32:
79 ; LA64F-NEXT: frsqrt.s $fa0, $fa0
82 ; LA64D-LABEL: frsqrt_f32:
84 ; LA64D-NEXT: frsqrt.s $fa0, $fa0
86 %1 = call float @llvm.sqrt.f32(float %a)
87 %2 = fdiv float 1.0, %1
91 define double @frsqrt_f64(double %a) nounwind {
92 ; LA32F-LABEL: frsqrt_f64:
94 ; LA32F-NEXT: addi.w $sp, $sp, -16
95 ; LA32F-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
96 ; LA32F-NEXT: bl %plt(sqrt)
97 ; LA32F-NEXT: move $a2, $a0
98 ; LA32F-NEXT: move $a3, $a1
99 ; LA32F-NEXT: lu12i.w $a1, 261888
100 ; LA32F-NEXT: move $a0, $zero
101 ; LA32F-NEXT: bl %plt(__divdf3)
102 ; LA32F-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
103 ; LA32F-NEXT: addi.w $sp, $sp, 16
106 ; LA32D-LABEL: frsqrt_f64:
108 ; LA32D-NEXT: frsqrt.d $fa0, $fa0
111 ; LA64F-LABEL: frsqrt_f64:
113 ; LA64F-NEXT: addi.d $sp, $sp, -16
114 ; LA64F-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
115 ; LA64F-NEXT: bl %plt(sqrt)
116 ; LA64F-NEXT: move $a1, $a0
117 ; LA64F-NEXT: lu52i.d $a0, $zero, 1023
118 ; LA64F-NEXT: bl %plt(__divdf3)
119 ; LA64F-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
120 ; LA64F-NEXT: addi.d $sp, $sp, 16
123 ; LA64D-LABEL: frsqrt_f64:
125 ; LA64D-NEXT: frsqrt.d $fa0, $fa0
127 %1 = call double @llvm.sqrt.f64(double %a)
128 %2 = fdiv double 1.0, %1