1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2 ; RUN: llc -mtriple=riscv32 -mattr=+f,+d,+zfh,+m,+v -global-isel -global-isel-abort=1 -verify-machineinstrs < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,RV32
3 ; RUN: llc -mtriple=riscv64 -mattr=+f,+d,+zfh,+m,+v -global-isel -global-isel-abort=1 -verify-machineinstrs < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,RV64
5 define i32 @freeze_int(i32 %x) {
6 ; RV32-LABEL: freeze_int:
8 ; RV32-NEXT: mul a0, a0, a0
11 ; RV64-LABEL: freeze_int:
13 ; RV64-NEXT: mulw a0, a0, a0
16 %t1 = mul i32 %y1, %y1
20 define i5 @freeze_int2(i5 %x) {
21 ; RV32-LABEL: freeze_int2:
23 ; RV32-NEXT: mul a0, a0, a0
26 ; RV64-LABEL: freeze_int2:
28 ; RV64-NEXT: mulw a0, a0, a0
35 define float @freeze_float(float %x) {
36 ; CHECK-LABEL: freeze_float:
38 ; CHECK-NEXT: fadd.s fa0, fa0, fa0
41 %t1 = fadd float %y1, %y1
45 define double @freeze_double(double %x) nounwind {
46 ; RV32-LABEL: freeze_double:
48 ; RV32-NEXT: addi sp, sp, -16
49 ; RV32-NEXT: fsd fa0, 8(sp)
50 ; RV32-NEXT: lw a0, 8(sp)
51 ; RV32-NEXT: lw a1, 12(sp)
52 ; RV32-NEXT: sw a0, 8(sp)
53 ; RV32-NEXT: sw a1, 12(sp)
54 ; RV32-NEXT: fld fa5, 8(sp)
55 ; RV32-NEXT: fadd.d fa0, fa5, fa5
56 ; RV32-NEXT: addi sp, sp, 16
59 ; RV64-LABEL: freeze_double:
61 ; RV64-NEXT: fadd.d fa0, fa0, fa0
63 %y1 = freeze double %x
64 %t1 = fadd double %y1, %y1
68 define void @freeze_half(ptr %p) {
69 ; CHECK-LABEL: freeze_half:
71 ; CHECK-NEXT: lh a1, 0(a0)
72 ; CHECK-NEXT: sh a1, 0(a0)
74 %x = load half, ptr %p
76 store half %y1, ptr %p
80 define <vscale x 2 x i32> @freeze_ivec(<vscale x 2 x i32> %x) {
81 ; CHECK-LABEL: freeze_ivec:
84 %y = freeze <vscale x 2 x i32> %x
85 ret <vscale x 2 x i32> %y
88 define <vscale x 2 x float> @freeze_fvec(<vscale x 2 x float> %x) {
89 ; CHECK-LABEL: freeze_fvec:
92 %y = freeze <vscale x 2 x float> %x
93 ret <vscale x 2 x float> %y
96 define ptr @freeze_ptr(ptr %x) {
97 ; CHECK-LABEL: freeze_ptr:
99 ; CHECK-NEXT: addi a0, a0, 4
102 %t1 = getelementptr i8, ptr %y1, i64 4
106 %struct.T = type { i32, i32 }
108 define i32 @freeze_struct(ptr %p) {
109 ; RV32-LABEL: freeze_struct:
111 ; RV32-NEXT: lw a1, 0(a0)
112 ; RV32-NEXT: lw a0, 4(a0)
113 ; RV32-NEXT: add a0, a1, a0
116 ; RV64-LABEL: freeze_struct:
118 ; RV64-NEXT: lw a1, 0(a0)
119 ; RV64-NEXT: lw a0, 4(a0)
120 ; RV64-NEXT: addw a0, a1, a0
122 %s = load %struct.T, ptr %p
123 %y1 = freeze %struct.T %s
124 %v1 = extractvalue %struct.T %y1, 0
125 %v2 = extractvalue %struct.T %y1, 1
126 %t1 = add i32 %v1, %v2
130 define i32 @freeze_anonstruct(ptr %p) {
131 ; RV32-LABEL: freeze_anonstruct:
133 ; RV32-NEXT: lw a1, 0(a0)
134 ; RV32-NEXT: lw a0, 4(a0)
135 ; RV32-NEXT: add a0, a1, a0
138 ; RV64-LABEL: freeze_anonstruct:
140 ; RV64-NEXT: lw a1, 0(a0)
141 ; RV64-NEXT: lw a0, 4(a0)
142 ; RV64-NEXT: addw a0, a1, a0
144 %s = load {i32, i32}, ptr %p
145 %y1 = freeze {i32, i32} %s
146 %v1 = extractvalue {i32, i32} %y1, 0
147 %v2 = extractvalue {i32, i32} %y1, 1
148 %t1 = add i32 %v1, %v2
152 define i32 @freeze_anonstruct2(ptr %p) {
153 ; RV32-LABEL: freeze_anonstruct2:
155 ; RV32-NEXT: lh a1, 4(a0)
156 ; RV32-NEXT: lw a0, 0(a0)
157 ; RV32-NEXT: lui a2, 16
158 ; RV32-NEXT: addi a2, a2, -1
159 ; RV32-NEXT: and a1, a1, a2
160 ; RV32-NEXT: add a0, a0, a1
163 ; RV64-LABEL: freeze_anonstruct2:
165 ; RV64-NEXT: lh a1, 4(a0)
166 ; RV64-NEXT: lw a0, 0(a0)
167 ; RV64-NEXT: lui a2, 16
168 ; RV64-NEXT: addi a2, a2, -1
169 ; RV64-NEXT: and a1, a1, a2
170 ; RV64-NEXT: addw a0, a0, a1
172 %s = load {i32, i16}, ptr %p
173 %y1 = freeze {i32, i16} %s
174 %v1 = extractvalue {i32, i16} %y1, 0
175 %v2 = extractvalue {i32, i16} %y1, 1
176 %z2 = zext i16 %v2 to i32
177 %t1 = add i32 %v1, %z2
181 define i32 @freeze_array(ptr %p) nounwind {
182 ; RV32-LABEL: freeze_array:
184 ; RV32-NEXT: lw a1, 0(a0)
185 ; RV32-NEXT: lw a0, 4(a0)
186 ; RV32-NEXT: add a0, a1, a0
189 ; RV64-LABEL: freeze_array:
191 ; RV64-NEXT: lw a1, 0(a0)
192 ; RV64-NEXT: lw a0, 4(a0)
193 ; RV64-NEXT: addw a0, a1, a0
195 %s = load [2 x i32], ptr %p
196 %y1 = freeze [2 x i32] %s
197 %v1 = extractvalue [2 x i32] %y1, 0
198 %v2 = extractvalue [2 x i32] %y1, 1
199 %t1 = add i32 %v1, %v2