1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr +d -target-abi ilp32d < %s | FileCheck %s
4 define void @test_load_store(half* %p, half* %q) nounwind {
5 ; CHECK-LABEL: test_load_store:
7 ; CHECK-NEXT: lh a0, 0(a0)
8 ; CHECK-NEXT: sh a0, 0(a1)
10 %a = load half, half* %p
11 store half %a, half* %q
15 define float @test_fpextend_float(half* %p) nounwind {
16 ; CHECK-LABEL: test_fpextend_float:
18 ; CHECK-NEXT: addi sp, sp, -16
19 ; CHECK-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
20 ; CHECK-NEXT: lhu a0, 0(a0)
21 ; CHECK-NEXT: call __gnu_h2f_ieee@plt
22 ; CHECK-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
23 ; CHECK-NEXT: addi sp, sp, 16
25 %a = load half, half* %p
26 %r = fpext half %a to float
30 define double @test_fpextend_double(half* %p) nounwind {
31 ; CHECK-LABEL: test_fpextend_double:
33 ; CHECK-NEXT: addi sp, sp, -16
34 ; CHECK-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
35 ; CHECK-NEXT: lhu a0, 0(a0)
36 ; CHECK-NEXT: call __gnu_h2f_ieee@plt
37 ; CHECK-NEXT: fcvt.d.s fa0, fa0
38 ; CHECK-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
39 ; CHECK-NEXT: addi sp, sp, 16
41 %a = load half, half* %p
42 %r = fpext half %a to double
46 define void @test_fptrunc_float(float %f, half* %p) nounwind {
47 ; CHECK-LABEL: test_fptrunc_float:
49 ; CHECK-NEXT: addi sp, sp, -16
50 ; CHECK-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
51 ; CHECK-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
52 ; CHECK-NEXT: mv s0, a0
53 ; CHECK-NEXT: call __gnu_f2h_ieee@plt
54 ; CHECK-NEXT: sh a0, 0(s0)
55 ; CHECK-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
56 ; CHECK-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
57 ; CHECK-NEXT: addi sp, sp, 16
59 %a = fptrunc float %f to half
60 store half %a, half* %p
64 define void @test_fptrunc_double(double %d, half* %p) nounwind {
65 ; CHECK-LABEL: test_fptrunc_double:
67 ; CHECK-NEXT: addi sp, sp, -16
68 ; CHECK-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
69 ; CHECK-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
70 ; CHECK-NEXT: mv s0, a0
71 ; CHECK-NEXT: call __truncdfhf2@plt
72 ; CHECK-NEXT: sh a0, 0(s0)
73 ; CHECK-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
74 ; CHECK-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
75 ; CHECK-NEXT: addi sp, sp, 16
77 %a = fptrunc double %d to half
78 store half %a, half* %p
82 define void @test_fadd(half* %p, half* %q) nounwind {
83 ; CHECK-LABEL: test_fadd:
85 ; CHECK-NEXT: addi sp, sp, -32
86 ; CHECK-NEXT: sw ra, 28(sp) # 4-byte Folded Spill
87 ; CHECK-NEXT: sw s0, 24(sp) # 4-byte Folded Spill
88 ; CHECK-NEXT: sw s1, 20(sp) # 4-byte Folded Spill
89 ; CHECK-NEXT: fsd fs0, 8(sp) # 8-byte Folded Spill
90 ; CHECK-NEXT: mv s0, a0
91 ; CHECK-NEXT: lhu s1, 0(a0)
92 ; CHECK-NEXT: lhu a0, 0(a1)
93 ; CHECK-NEXT: call __gnu_h2f_ieee@plt
94 ; CHECK-NEXT: fmv.s fs0, fa0
95 ; CHECK-NEXT: mv a0, s1
96 ; CHECK-NEXT: call __gnu_h2f_ieee@plt
97 ; CHECK-NEXT: fadd.s fa0, fa0, fs0
98 ; CHECK-NEXT: call __gnu_f2h_ieee@plt
99 ; CHECK-NEXT: sh a0, 0(s0)
100 ; CHECK-NEXT: fld fs0, 8(sp) # 8-byte Folded Reload
101 ; CHECK-NEXT: lw s1, 20(sp) # 4-byte Folded Reload
102 ; CHECK-NEXT: lw s0, 24(sp) # 4-byte Folded Reload
103 ; CHECK-NEXT: lw ra, 28(sp) # 4-byte Folded Reload
104 ; CHECK-NEXT: addi sp, sp, 32
106 %a = load half, half* %p
107 %b = load half, half* %q
108 %r = fadd half %a, %b
109 store half %r, half* %p
113 define void @test_fmul(half* %p, half* %q) nounwind {
114 ; CHECK-LABEL: test_fmul:
116 ; CHECK-NEXT: addi sp, sp, -32
117 ; CHECK-NEXT: sw ra, 28(sp) # 4-byte Folded Spill
118 ; CHECK-NEXT: sw s0, 24(sp) # 4-byte Folded Spill
119 ; CHECK-NEXT: sw s1, 20(sp) # 4-byte Folded Spill
120 ; CHECK-NEXT: fsd fs0, 8(sp) # 8-byte Folded Spill
121 ; CHECK-NEXT: mv s0, a0
122 ; CHECK-NEXT: lhu s1, 0(a0)
123 ; CHECK-NEXT: lhu a0, 0(a1)
124 ; CHECK-NEXT: call __gnu_h2f_ieee@plt
125 ; CHECK-NEXT: fmv.s fs0, fa0
126 ; CHECK-NEXT: mv a0, s1
127 ; CHECK-NEXT: call __gnu_h2f_ieee@plt
128 ; CHECK-NEXT: fmul.s fa0, fa0, fs0
129 ; CHECK-NEXT: call __gnu_f2h_ieee@plt
130 ; CHECK-NEXT: sh a0, 0(s0)
131 ; CHECK-NEXT: fld fs0, 8(sp) # 8-byte Folded Reload
132 ; CHECK-NEXT: lw s1, 20(sp) # 4-byte Folded Reload
133 ; CHECK-NEXT: lw s0, 24(sp) # 4-byte Folded Reload
134 ; CHECK-NEXT: lw ra, 28(sp) # 4-byte Folded Reload
135 ; CHECK-NEXT: addi sp, sp, 32
137 %a = load half, half* %p
138 %b = load half, half* %q
139 %r = fmul half %a, %b
140 store half %r, half* %p