1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
2 ; RUN: llc -mtriple=riscv32 -mattr=+zdinx -verify-machineinstrs < %s \
3 ; RUN: -target-abi=ilp32 -mattr=+zhinx | FileCheck %s
5 ;; These tests cover the use of `r`, `R`, and `cr` constraints for floating point values on rv32.
7 ;; In particular, there is significant complexity around using paired GPRs for double values on rv32.
9 define dso_local void @zdinx_asm(ptr nocapture noundef writeonly %a, double noundef %b, double noundef %c) nounwind {
10 ; CHECK-LABEL: zdinx_asm:
11 ; CHECK: # %bb.0: # %entry
12 ; CHECK-NEXT: mv a5, a4
13 ; CHECK-NEXT: mv a7, a2
14 ; CHECK-NEXT: mv a4, a3
15 ; CHECK-NEXT: mv a6, a1
17 ; CHECK-NEXT: fsgnjx.d a2, a6, a4
19 ; CHECK-NEXT: sw a2, 8(a0)
20 ; CHECK-NEXT: sw a3, 12(a0)
23 %arrayidx = getelementptr inbounds double, ptr %a, i32 1
24 %0 = tail call double asm "fsgnjx.d $0, $1, $2", "=r,r,r"(double %b, double %c)
25 store double %0, ptr %arrayidx, align 8
29 define dso_local void @zdinx_asm_R(ptr nocapture noundef writeonly %a, double noundef %b, double noundef %c) nounwind {
30 ; CHECK-LABEL: zdinx_asm_R:
31 ; CHECK: # %bb.0: # %entry
32 ; CHECK-NEXT: mv a5, a4
33 ; CHECK-NEXT: mv a7, a2
34 ; CHECK-NEXT: mv a4, a3
35 ; CHECK-NEXT: mv a6, a1
37 ; CHECK-NEXT: fsgnjx.d a2, a6, a4
39 ; CHECK-NEXT: sw a2, 8(a0)
40 ; CHECK-NEXT: sw a3, 12(a0)
43 %arrayidx = getelementptr inbounds double, ptr %a, i32 1
44 %0 = tail call double asm "fsgnjx.d $0, $1, $2", "=R,R,R"(double %b, double %c)
45 store double %0, ptr %arrayidx, align 8
49 define dso_local void @zdinx_asm_inout(ptr nocapture noundef writeonly %a, double noundef %b) nounwind {
50 ; CHECK-LABEL: zdinx_asm_inout:
51 ; CHECK: # %bb.0: # %entry
52 ; CHECK-NEXT: mv a3, a2
53 ; CHECK-NEXT: mv a2, a1
55 ; CHECK-NEXT: fmv.d a2, a2
57 ; CHECK-NEXT: sw a2, 8(a0)
58 ; CHECK-NEXT: sw a3, 12(a0)
61 %arrayidx = getelementptr inbounds double, ptr %a, i32 1
62 %0 = tail call double asm "fsgnj.d $0, $1, $1", "=r,0"(double %b)
63 store double %0, ptr %arrayidx, align 8
67 define dso_local void @zdinx_asm_Pr_inout(ptr nocapture noundef writeonly %a, double noundef %b) nounwind {
68 ; CHECK-LABEL: zdinx_asm_Pr_inout:
69 ; CHECK: # %bb.0: # %entry
70 ; CHECK-NEXT: mv a3, a2
71 ; CHECK-NEXT: mv a2, a1
73 ; CHECK-NEXT: fabs.d a2, a2
75 ; CHECK-NEXT: sw a2, 8(a0)
76 ; CHECK-NEXT: sw a3, 12(a0)
79 %arrayidx = getelementptr inbounds double, ptr %a, i32 1
80 %0 = tail call double asm "fsgnjx.d $0, $1, $1", "=R,0"(double %b)
81 store double %0, ptr %arrayidx, align 8
85 define dso_local void @zfinx_asm(ptr nocapture noundef writeonly %a, float noundef %b, float noundef %c) nounwind {
86 ; CHECK-LABEL: zfinx_asm:
87 ; CHECK: # %bb.0: # %entry
89 ; CHECK-NEXT: fsgnjx.s a1, a1, a2
91 ; CHECK-NEXT: sw a1, 4(a0)
94 %arrayidx = getelementptr inbounds float, ptr %a, i32 1
95 %0 = tail call float asm "fsgnjx.s $0, $1, $2", "=r,r,r"(float %b, float %c)
96 store float %0, ptr %arrayidx, align 8
100 define dso_local void @zhinx_asm(ptr nocapture noundef writeonly %a, half noundef %b, half noundef %c) nounwind {
101 ; CHECK-LABEL: zhinx_asm:
102 ; CHECK: # %bb.0: # %entry
104 ; CHECK-NEXT: fsgnjx.h a1, a1, a2
105 ; CHECK-NEXT: #NO_APP
106 ; CHECK-NEXT: sh a1, 2(a0)
109 %arrayidx = getelementptr inbounds half, ptr %a, i32 1
110 %0 = tail call half asm "fsgnjx.h $0, $1, $2", "=r,r,r"(half %b, half %c)
111 store half %0, ptr %arrayidx, align 8
115 define dso_local void @zdinx_asm_cr(ptr nocapture noundef writeonly %a, double noundef %b, double noundef %c) nounwind {
116 ; CHECK-LABEL: zdinx_asm_cr:
117 ; CHECK: # %bb.0: # %entry
118 ; CHECK-NEXT: addi sp, sp, -16
119 ; CHECK-NEXT: sw s0, 12(sp) # 4-byte Folded Spill
120 ; CHECK-NEXT: sw s1, 8(sp) # 4-byte Folded Spill
121 ; CHECK-NEXT: mv a5, a4
122 ; CHECK-NEXT: mv s1, a2
123 ; CHECK-NEXT: mv a4, a3
124 ; CHECK-NEXT: mv s0, a1
126 ; CHECK-NEXT: fsgnjx.d a2, s0, a4
127 ; CHECK-NEXT: #NO_APP
128 ; CHECK-NEXT: sw a2, 8(a0)
129 ; CHECK-NEXT: sw a3, 12(a0)
130 ; CHECK-NEXT: lw s0, 12(sp) # 4-byte Folded Reload
131 ; CHECK-NEXT: lw s1, 8(sp) # 4-byte Folded Reload
132 ; CHECK-NEXT: addi sp, sp, 16
135 %arrayidx = getelementptr inbounds double, ptr %a, i32 1
136 %0 = tail call double asm "fsgnjx.d $0, $1, $2", "=^cr,^cr,^cr"(double %b, double %c)
137 store double %0, ptr %arrayidx, align 8
141 define dso_local void @zfinx_asm_cr(ptr nocapture noundef writeonly %a, float noundef %b, float noundef %c) nounwind {
142 ; CHECK-LABEL: zfinx_asm_cr:
143 ; CHECK: # %bb.0: # %entry
145 ; CHECK-NEXT: fsgnjx.s a1, a1, a2
146 ; CHECK-NEXT: #NO_APP
147 ; CHECK-NEXT: sw a1, 4(a0)
150 %arrayidx = getelementptr inbounds float, ptr %a, i32 1
151 %0 = tail call float asm "fsgnjx.s $0, $1, $2", "=^cr,^cr,^cr"(float %b, float %c)
152 store float %0, ptr %arrayidx, align 8
156 define dso_local void @zhinx_asm_cr(ptr nocapture noundef writeonly %a, half noundef %b, half noundef %c) nounwind {
157 ; CHECK-LABEL: zhinx_asm_cr:
158 ; CHECK: # %bb.0: # %entry
160 ; CHECK-NEXT: fsgnjx.h a1, a1, a2
161 ; CHECK-NEXT: #NO_APP
162 ; CHECK-NEXT: sh a1, 2(a0)
165 %arrayidx = getelementptr inbounds half, ptr %a, i32 1
166 %0 = tail call half asm "fsgnjx.h $0, $1, $2", "=^cr,^cr,^cr"(half %b, half %c)
167 store half %0, ptr %arrayidx, align 8