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.copysign.f32(float, float)
8 declare double @llvm.copysign.f64(double, double)
10 define float @fcopysign_s(float %a, float %b) nounwind {
11 ; LA32F-LABEL: fcopysign_s:
13 ; LA32F-NEXT: fcopysign.s $fa0, $fa0, $fa1
16 ; LA32D-LABEL: fcopysign_s:
18 ; LA32D-NEXT: fcopysign.s $fa0, $fa0, $fa1
21 ; LA64F-LABEL: fcopysign_s:
23 ; LA64F-NEXT: fcopysign.s $fa0, $fa0, $fa1
26 ; LA64D-LABEL: fcopysign_s:
28 ; LA64D-NEXT: fcopysign.s $fa0, $fa0, $fa1
30 %1 = call float @llvm.copysign.f32(float %a, float %b)
34 define double @fcopysign_d(double %a, double %b) nounwind {
35 ; LA32F-LABEL: fcopysign_d:
37 ; LA32F-NEXT: srli.w $a2, $a3, 31
38 ; LA32F-NEXT: bstrins.w $a1, $a2, 31, 31
41 ; LA32D-LABEL: fcopysign_d:
43 ; LA32D-NEXT: fcopysign.d $fa0, $fa0, $fa1
46 ; LA64F-LABEL: fcopysign_d:
48 ; LA64F-NEXT: srli.d $a1, $a1, 63
49 ; LA64F-NEXT: bstrins.d $a0, $a1, 63, 63
52 ; LA64D-LABEL: fcopysign_d:
54 ; LA64D-NEXT: fcopysign.d $fa0, $fa0, $fa1
56 %1 = call double @llvm.copysign.f64(double %a, double %b)
60 define double @fold_promote_d_s(double %a, float %b) nounwind {
61 ; LA32F-LABEL: fold_promote_d_s:
63 ; LA32F-NEXT: movfr2gr.s $a2, $fa0
64 ; LA32F-NEXT: srli.w $a2, $a2, 31
65 ; LA32F-NEXT: bstrins.w $a1, $a2, 31, 31
68 ; LA32D-LABEL: fold_promote_d_s:
70 ; LA32D-NEXT: fcvt.d.s $fa1, $fa1
71 ; LA32D-NEXT: fcopysign.d $fa0, $fa0, $fa1
74 ; LA64F-LABEL: fold_promote_d_s:
76 ; LA64F-NEXT: movfr2gr.s $a1, $fa0
77 ; LA64F-NEXT: lu12i.w $a2, -524288
78 ; LA64F-NEXT: lu32i.d $a2, 0
79 ; LA64F-NEXT: and $a1, $a1, $a2
80 ; LA64F-NEXT: slli.d $a1, $a1, 32
81 ; LA64F-NEXT: bstrins.d $a1, $a0, 62, 0
82 ; LA64F-NEXT: move $a0, $a1
85 ; LA64D-LABEL: fold_promote_d_s:
87 ; LA64D-NEXT: fcvt.d.s $fa1, $fa1
88 ; LA64D-NEXT: fcopysign.d $fa0, $fa0, $fa1
90 %c = fpext float %b to double
91 %t = call double @llvm.copysign.f64(double %a, double %c)
95 define float @fold_demote_s_d(float %a, double %b) nounwind {
96 ; LA32F-LABEL: fold_demote_s_d:
98 ; LA32F-NEXT: movgr2fr.w $fa1, $a1
99 ; LA32F-NEXT: fcopysign.s $fa0, $fa0, $fa1
102 ; LA32D-LABEL: fold_demote_s_d:
104 ; LA32D-NEXT: fcvt.s.d $fa1, $fa1
105 ; LA32D-NEXT: fcopysign.s $fa0, $fa0, $fa1
108 ; LA64F-LABEL: fold_demote_s_d:
110 ; LA64F-NEXT: srli.d $a0, $a0, 32
111 ; LA64F-NEXT: movgr2fr.w $fa1, $a0
112 ; LA64F-NEXT: fcopysign.s $fa0, $fa0, $fa1
115 ; LA64D-LABEL: fold_demote_s_d:
117 ; LA64D-NEXT: fcvt.s.d $fa1, $fa1
118 ; LA64D-NEXT: fcopysign.s $fa0, $fa0, $fa1
120 %c = fptrunc double %b to float
121 %t = call float @llvm.copysign.f32(float %a, float %c)