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 | 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 | FileCheck %s --check-prefixes=CHECK,RV64
5 define i32 @freeze_int(i32 %x) {
6 ; CHECK-LABEL: freeze_int:
8 ; CHECK-NEXT: mul a0, a0, a0
11 %t1 = mul i32 %y1, %y1
15 define i5 @freeze_int2(i5 %x) {
16 ; CHECK-LABEL: freeze_int2:
18 ; CHECK-NEXT: mul a0, a0, a0
25 define float @freeze_float(float %x) {
26 ; CHECK-LABEL: freeze_float:
28 ; CHECK-NEXT: fadd.s fa0, fa0, fa0
31 %t1 = fadd float %y1, %y1
35 define double @freeze_double(double %x) nounwind {
36 ; RV32-LABEL: freeze_double:
38 ; RV32-NEXT: addi sp, sp, -16
39 ; RV32-NEXT: fsd fa0, 8(sp)
40 ; RV32-NEXT: lw a0, 8(sp)
41 ; RV32-NEXT: lw a1, 12(sp)
42 ; RV32-NEXT: sw a0, 8(sp)
43 ; RV32-NEXT: sw a1, 12(sp)
44 ; RV32-NEXT: fld fa5, 8(sp)
45 ; RV32-NEXT: fadd.d fa0, fa5, fa5
46 ; RV32-NEXT: addi sp, sp, 16
49 ; RV64-LABEL: freeze_double:
51 ; RV64-NEXT: fadd.d fa0, fa0, fa0
53 %y1 = freeze double %x
54 %t1 = fadd double %y1, %y1
58 define void @freeze_half(ptr %p) {
59 ; CHECK-LABEL: freeze_half:
61 ; CHECK-NEXT: lh a1, 0(a0)
62 ; CHECK-NEXT: sh a1, 0(a0)
64 %x = load half, ptr %p
66 store half %y1, ptr %p
70 define <vscale x 2 x i32> @freeze_ivec(<vscale x 2 x i32> %x) {
71 ; CHECK-LABEL: freeze_ivec:
74 %y = freeze <vscale x 2 x i32> %x
75 ret <vscale x 2 x i32> %y
78 define <vscale x 2 x float> @freeze_fvec(<vscale x 2 x float> %x) {
79 ; CHECK-LABEL: freeze_fvec:
82 %y = freeze <vscale x 2 x float> %x
83 ret <vscale x 2 x float> %y
86 define ptr @freeze_ptr(ptr %x) {
87 ; CHECK-LABEL: freeze_ptr:
89 ; CHECK-NEXT: addi a0, a0, 4
92 %t1 = getelementptr i8, ptr %y1, i64 4
96 %struct.T = type { i32, i32 }
98 define i32 @freeze_struct(ptr %p) {
99 ; CHECK-LABEL: freeze_struct:
101 ; CHECK-NEXT: lw a1, 0(a0)
102 ; CHECK-NEXT: lw a0, 4(a0)
103 ; CHECK-NEXT: add a0, a1, a0
105 %s = load %struct.T, ptr %p
106 %y1 = freeze %struct.T %s
107 %v1 = extractvalue %struct.T %y1, 0
108 %v2 = extractvalue %struct.T %y1, 1
109 %t1 = add i32 %v1, %v2
113 define i32 @freeze_anonstruct(ptr %p) {
114 ; CHECK-LABEL: freeze_anonstruct:
116 ; CHECK-NEXT: lw a1, 0(a0)
117 ; CHECK-NEXT: lw a0, 4(a0)
118 ; CHECK-NEXT: add a0, a1, a0
120 %s = load {i32, i32}, ptr %p
121 %y1 = freeze {i32, i32} %s
122 %v1 = extractvalue {i32, i32} %y1, 0
123 %v2 = extractvalue {i32, i32} %y1, 1
124 %t1 = add i32 %v1, %v2
128 define i32 @freeze_anonstruct2(ptr %p) {
129 ; RV32-LABEL: freeze_anonstruct2:
131 ; RV32-NEXT: lh a1, 4(a0)
132 ; RV32-NEXT: lw a0, 0(a0)
133 ; RV32-NEXT: slli a1, a1, 16
134 ; RV32-NEXT: srli a1, a1, 16
135 ; RV32-NEXT: add a0, a0, a1
138 ; RV64-LABEL: freeze_anonstruct2:
140 ; RV64-NEXT: lh a1, 4(a0)
141 ; RV64-NEXT: lw a0, 0(a0)
142 ; RV64-NEXT: slli a1, a1, 48
143 ; RV64-NEXT: srli a1, a1, 48
144 ; RV64-NEXT: add a0, a0, a1
146 %s = load {i32, i16}, ptr %p
147 %y1 = freeze {i32, i16} %s
148 %v1 = extractvalue {i32, i16} %y1, 0
149 %v2 = extractvalue {i32, i16} %y1, 1
150 %z2 = zext i16 %v2 to i32
151 %t1 = add i32 %v1, %z2
155 define i32 @freeze_anonstruct2_sext(ptr %p) {
156 ; RV32-LABEL: freeze_anonstruct2_sext:
158 ; RV32-NEXT: lh a1, 4(a0)
159 ; RV32-NEXT: lw a0, 0(a0)
160 ; RV32-NEXT: slli a1, a1, 16
161 ; RV32-NEXT: srai a1, a1, 16
162 ; RV32-NEXT: add a0, a0, a1
165 ; RV64-LABEL: freeze_anonstruct2_sext:
167 ; RV64-NEXT: lh a1, 4(a0)
168 ; RV64-NEXT: lw a0, 0(a0)
169 ; RV64-NEXT: slli a1, a1, 48
170 ; RV64-NEXT: srai a1, a1, 48
171 ; RV64-NEXT: add a0, a0, a1
173 %s = load {i32, i16}, ptr %p
174 %y1 = freeze {i32, i16} %s
175 %v1 = extractvalue {i32, i16} %y1, 0
176 %v2 = extractvalue {i32, i16} %y1, 1
177 %z2 = sext i16 %v2 to i32
178 %t1 = add i32 %v1, %z2
182 define i32 @freeze_array(ptr %p) nounwind {
183 ; CHECK-LABEL: freeze_array:
185 ; CHECK-NEXT: lw a1, 0(a0)
186 ; CHECK-NEXT: lw a0, 4(a0)
187 ; CHECK-NEXT: add a0, a1, a0
189 %s = load [2 x i32], ptr %p
190 %y1 = freeze [2 x i32] %s
191 %v1 = extractvalue [2 x i32] %y1, 0
192 %v2 = extractvalue [2 x i32] %y1, 1
193 %t1 = add i32 %v1, %v2