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.maxnum.f32(float, float)
8 declare double @llvm.maxnum.f64(double, double)
9 declare float @llvm.minnum.f32(float, float)
10 declare double @llvm.minnum.f64(double, double)
12 define float @maxnum_float(float %x, float %y) {
13 ; LA32F-LABEL: maxnum_float:
15 ; LA32F-NEXT: fmax.s $fa1, $fa1, $fa1
16 ; LA32F-NEXT: fmax.s $fa0, $fa0, $fa0
17 ; LA32F-NEXT: fmax.s $fa0, $fa0, $fa1
20 ; LA32D-LABEL: maxnum_float:
22 ; LA32D-NEXT: fmax.s $fa1, $fa1, $fa1
23 ; LA32D-NEXT: fmax.s $fa0, $fa0, $fa0
24 ; LA32D-NEXT: fmax.s $fa0, $fa0, $fa1
27 ; LA64F-LABEL: maxnum_float:
29 ; LA64F-NEXT: fmax.s $fa1, $fa1, $fa1
30 ; LA64F-NEXT: fmax.s $fa0, $fa0, $fa0
31 ; LA64F-NEXT: fmax.s $fa0, $fa0, $fa1
34 ; LA64D-LABEL: maxnum_float:
36 ; LA64D-NEXT: fmax.s $fa1, $fa1, $fa1
37 ; LA64D-NEXT: fmax.s $fa0, $fa0, $fa0
38 ; LA64D-NEXT: fmax.s $fa0, $fa0, $fa1
40 %z = call float @llvm.maxnum.f32(float %x, float %y)
44 define double @maxnum_double(double %x, double %y) {
45 ; LA32F-LABEL: maxnum_double:
47 ; LA32F-NEXT: addi.w $sp, $sp, -16
48 ; LA32F-NEXT: .cfi_def_cfa_offset 16
49 ; LA32F-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
50 ; LA32F-NEXT: .cfi_offset 1, -4
51 ; LA32F-NEXT: bl %plt(fmax)
52 ; LA32F-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
53 ; LA32F-NEXT: addi.w $sp, $sp, 16
56 ; LA32D-LABEL: maxnum_double:
58 ; LA32D-NEXT: fmax.d $fa1, $fa1, $fa1
59 ; LA32D-NEXT: fmax.d $fa0, $fa0, $fa0
60 ; LA32D-NEXT: fmax.d $fa0, $fa0, $fa1
63 ; LA64F-LABEL: maxnum_double:
65 ; LA64F-NEXT: addi.d $sp, $sp, -16
66 ; LA64F-NEXT: .cfi_def_cfa_offset 16
67 ; LA64F-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
68 ; LA64F-NEXT: .cfi_offset 1, -8
69 ; LA64F-NEXT: bl %plt(fmax)
70 ; LA64F-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
71 ; LA64F-NEXT: addi.d $sp, $sp, 16
74 ; LA64D-LABEL: maxnum_double:
76 ; LA64D-NEXT: fmax.d $fa1, $fa1, $fa1
77 ; LA64D-NEXT: fmax.d $fa0, $fa0, $fa0
78 ; LA64D-NEXT: fmax.d $fa0, $fa0, $fa1
80 %z = call double @llvm.maxnum.f64(double %x, double %y)
84 define float @minnum_float(float %x, float %y) {
85 ; LA32F-LABEL: minnum_float:
87 ; LA32F-NEXT: fmax.s $fa1, $fa1, $fa1
88 ; LA32F-NEXT: fmax.s $fa0, $fa0, $fa0
89 ; LA32F-NEXT: fmin.s $fa0, $fa0, $fa1
92 ; LA32D-LABEL: minnum_float:
94 ; LA32D-NEXT: fmax.s $fa1, $fa1, $fa1
95 ; LA32D-NEXT: fmax.s $fa0, $fa0, $fa0
96 ; LA32D-NEXT: fmin.s $fa0, $fa0, $fa1
99 ; LA64F-LABEL: minnum_float:
101 ; LA64F-NEXT: fmax.s $fa1, $fa1, $fa1
102 ; LA64F-NEXT: fmax.s $fa0, $fa0, $fa0
103 ; LA64F-NEXT: fmin.s $fa0, $fa0, $fa1
106 ; LA64D-LABEL: minnum_float:
108 ; LA64D-NEXT: fmax.s $fa1, $fa1, $fa1
109 ; LA64D-NEXT: fmax.s $fa0, $fa0, $fa0
110 ; LA64D-NEXT: fmin.s $fa0, $fa0, $fa1
112 %z = call float @llvm.minnum.f32(float %x, float %y)
116 define double @minnum_double(double %x, double %y) {
117 ; LA32F-LABEL: minnum_double:
119 ; LA32F-NEXT: addi.w $sp, $sp, -16
120 ; LA32F-NEXT: .cfi_def_cfa_offset 16
121 ; LA32F-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
122 ; LA32F-NEXT: .cfi_offset 1, -4
123 ; LA32F-NEXT: bl %plt(fmin)
124 ; LA32F-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
125 ; LA32F-NEXT: addi.w $sp, $sp, 16
128 ; LA32D-LABEL: minnum_double:
130 ; LA32D-NEXT: fmax.d $fa1, $fa1, $fa1
131 ; LA32D-NEXT: fmax.d $fa0, $fa0, $fa0
132 ; LA32D-NEXT: fmin.d $fa0, $fa0, $fa1
135 ; LA64F-LABEL: minnum_double:
137 ; LA64F-NEXT: addi.d $sp, $sp, -16
138 ; LA64F-NEXT: .cfi_def_cfa_offset 16
139 ; LA64F-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
140 ; LA64F-NEXT: .cfi_offset 1, -8
141 ; LA64F-NEXT: bl %plt(fmin)
142 ; LA64F-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
143 ; LA64F-NEXT: addi.d $sp, $sp, 16
146 ; LA64D-LABEL: minnum_double:
148 ; LA64D-NEXT: fmax.d $fa1, $fa1, $fa1
149 ; LA64D-NEXT: fmax.d $fa0, $fa0, $fa0
150 ; LA64D-NEXT: fmin.d $fa0, $fa0, $fa1
152 %z = call double @llvm.minnum.f64(double %x, double %y)