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(ptr %p, ptr %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, ptr %p
15 define float @test_fpextend_float(ptr %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: fmv.w.x fa0, a0
22 ; CHECK-NEXT: call __extendhfsf2
23 ; CHECK-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
24 ; CHECK-NEXT: addi sp, sp, 16
26 %a = load half, ptr %p
27 %r = fpext half %a to float
31 define double @test_fpextend_double(ptr %p) nounwind {
32 ; CHECK-LABEL: test_fpextend_double:
34 ; CHECK-NEXT: addi sp, sp, -16
35 ; CHECK-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
36 ; CHECK-NEXT: lhu a0, 0(a0)
37 ; CHECK-NEXT: fmv.w.x fa0, a0
38 ; CHECK-NEXT: call __extendhfsf2
39 ; CHECK-NEXT: fcvt.d.s fa0, fa0
40 ; CHECK-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
41 ; CHECK-NEXT: addi sp, sp, 16
43 %a = load half, ptr %p
44 %r = fpext half %a to double
48 define void @test_fptrunc_float(float %f, ptr %p) nounwind {
49 ; CHECK-LABEL: test_fptrunc_float:
51 ; CHECK-NEXT: addi sp, sp, -16
52 ; CHECK-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
53 ; CHECK-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
54 ; CHECK-NEXT: mv s0, a0
55 ; CHECK-NEXT: call __truncsfhf2
56 ; CHECK-NEXT: fmv.x.w a0, fa0
57 ; CHECK-NEXT: sh a0, 0(s0)
58 ; CHECK-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
59 ; CHECK-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
60 ; CHECK-NEXT: addi sp, sp, 16
62 %a = fptrunc float %f to half
67 define void @test_fptrunc_double(double %d, ptr %p) nounwind {
68 ; CHECK-LABEL: test_fptrunc_double:
70 ; CHECK-NEXT: addi sp, sp, -16
71 ; CHECK-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
72 ; CHECK-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
73 ; CHECK-NEXT: mv s0, a0
74 ; CHECK-NEXT: call __truncdfhf2
75 ; CHECK-NEXT: fmv.x.w a0, fa0
76 ; CHECK-NEXT: sh a0, 0(s0)
77 ; CHECK-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
78 ; CHECK-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
79 ; CHECK-NEXT: addi sp, sp, 16
81 %a = fptrunc double %d to half
86 define void @test_fadd(ptr %p, ptr %q) nounwind {
87 ; CHECK-LABEL: test_fadd:
89 ; CHECK-NEXT: addi sp, sp, -32
90 ; CHECK-NEXT: sw ra, 28(sp) # 4-byte Folded Spill
91 ; CHECK-NEXT: sw s0, 24(sp) # 4-byte Folded Spill
92 ; CHECK-NEXT: fsd fs0, 16(sp) # 8-byte Folded Spill
93 ; CHECK-NEXT: fsd fs1, 8(sp) # 8-byte Folded Spill
94 ; CHECK-NEXT: mv s0, a0
95 ; CHECK-NEXT: lhu a0, 0(a0)
96 ; CHECK-NEXT: lhu a1, 0(a1)
97 ; CHECK-NEXT: fmv.w.x fs0, a0
98 ; CHECK-NEXT: fmv.w.x fa0, a1
99 ; CHECK-NEXT: call __extendhfsf2
100 ; CHECK-NEXT: fmv.s fs1, fa0
101 ; CHECK-NEXT: fmv.s fa0, fs0
102 ; CHECK-NEXT: call __extendhfsf2
103 ; CHECK-NEXT: fadd.s fa0, fa0, fs1
104 ; CHECK-NEXT: call __truncsfhf2
105 ; CHECK-NEXT: fmv.x.w a0, fa0
106 ; CHECK-NEXT: sh a0, 0(s0)
107 ; CHECK-NEXT: lw ra, 28(sp) # 4-byte Folded Reload
108 ; CHECK-NEXT: lw s0, 24(sp) # 4-byte Folded Reload
109 ; CHECK-NEXT: fld fs0, 16(sp) # 8-byte Folded Reload
110 ; CHECK-NEXT: fld fs1, 8(sp) # 8-byte Folded Reload
111 ; CHECK-NEXT: addi sp, sp, 32
113 %a = load half, ptr %p
114 %b = load half, ptr %q
115 %r = fadd half %a, %b
116 store half %r, ptr %p
120 define void @test_fmul(ptr %p, ptr %q) nounwind {
121 ; CHECK-LABEL: test_fmul:
123 ; CHECK-NEXT: addi sp, sp, -32
124 ; CHECK-NEXT: sw ra, 28(sp) # 4-byte Folded Spill
125 ; CHECK-NEXT: sw s0, 24(sp) # 4-byte Folded Spill
126 ; CHECK-NEXT: fsd fs0, 16(sp) # 8-byte Folded Spill
127 ; CHECK-NEXT: fsd fs1, 8(sp) # 8-byte Folded Spill
128 ; CHECK-NEXT: mv s0, a0
129 ; CHECK-NEXT: lhu a0, 0(a0)
130 ; CHECK-NEXT: lhu a1, 0(a1)
131 ; CHECK-NEXT: fmv.w.x fs0, a0
132 ; CHECK-NEXT: fmv.w.x fa0, a1
133 ; CHECK-NEXT: call __extendhfsf2
134 ; CHECK-NEXT: fmv.s fs1, fa0
135 ; CHECK-NEXT: fmv.s fa0, fs0
136 ; CHECK-NEXT: call __extendhfsf2
137 ; CHECK-NEXT: fmul.s fa0, fa0, fs1
138 ; CHECK-NEXT: call __truncsfhf2
139 ; CHECK-NEXT: fmv.x.w a0, fa0
140 ; CHECK-NEXT: sh a0, 0(s0)
141 ; CHECK-NEXT: lw ra, 28(sp) # 4-byte Folded Reload
142 ; CHECK-NEXT: lw s0, 24(sp) # 4-byte Folded Reload
143 ; CHECK-NEXT: fld fs0, 16(sp) # 8-byte Folded Reload
144 ; CHECK-NEXT: fld fs1, 8(sp) # 8-byte Folded Reload
145 ; CHECK-NEXT: addi sp, sp, 32
147 %a = load half, ptr %p
148 %b = load half, ptr %q
149 %r = fmul half %a, %b
150 store half %r, ptr %p