1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=riscv64 -run-pass=legalizer %s -o - \
3 # RUN: | FileCheck %s --check-prefixes=CHECK,RV64I
4 # RUN: llc -mtriple=riscv64 -mattr=+zbb -run-pass=legalizer %s -o - \
5 # RUN: | FileCheck %s --check-prefixes=CHECK,RV64ZBB_OR_RV64ZBKB
6 # RUN: llc -mtriple=riscv64 -mattr=+zbkb -run-pass=legalizer %s -o - \
7 # RUN: | FileCheck %s --check-prefixes=CHECK,RV64ZBB_OR_RV64ZBKB
15 ; CHECK-LABEL: name: rotl_i8
16 ; CHECK: liveins: $x10, $x11
18 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
19 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
20 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
21 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 7
22 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[C]], [[COPY1]]
23 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY1]], [[C1]]
24 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 255
25 ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[AND]], [[C2]]
26 ; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY]], [[AND1]](s64)
27 ; CHECK-NEXT: [[AND2:%[0-9]+]]:_(s64) = G_AND [[SUB]], [[C1]]
28 ; CHECK-NEXT: [[AND3:%[0-9]+]]:_(s64) = G_AND [[COPY]], [[C2]]
29 ; CHECK-NEXT: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[AND3]], [[AND2]](s64)
30 ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[SHL]], [[LSHR]]
31 ; CHECK-NEXT: $x10 = COPY [[OR]](s64)
32 ; CHECK-NEXT: PseudoRET implicit $x10
34 %0:_(s8) = G_TRUNC %2(s64)
36 %1:_(s8) = G_TRUNC %3(s64)
37 %4:_(s8) = G_ROTL %0, %1(s8)
38 %5:_(s64) = G_ANYEXT %4(s8)
40 PseudoRET implicit $x10
49 ; CHECK-LABEL: name: rotl_i16
50 ; CHECK: liveins: $x10, $x11
52 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
53 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
54 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
55 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 15
56 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[C]], [[COPY1]]
57 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY1]], [[C1]]
58 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 65535
59 ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[AND]], [[C2]]
60 ; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY]], [[AND1]](s64)
61 ; CHECK-NEXT: [[AND2:%[0-9]+]]:_(s64) = G_AND [[SUB]], [[C1]]
62 ; CHECK-NEXT: [[AND3:%[0-9]+]]:_(s64) = G_AND [[COPY]], [[C2]]
63 ; CHECK-NEXT: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[AND3]], [[AND2]](s64)
64 ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[SHL]], [[LSHR]]
65 ; CHECK-NEXT: $x10 = COPY [[OR]](s64)
66 ; CHECK-NEXT: PseudoRET implicit $x10
68 %0:_(s16) = G_TRUNC %2(s64)
70 %1:_(s16) = G_TRUNC %3(s64)
71 %4:_(s16) = G_ROTL %0, %1(s16)
72 %5:_(s64) = G_ANYEXT %4(s16)
74 PseudoRET implicit $x10
83 ; RV64I-LABEL: name: rotl_i32
84 ; RV64I: liveins: $x10, $x11
86 ; RV64I-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
87 ; RV64I-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
88 ; RV64I-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
89 ; RV64I-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 31
90 ; RV64I-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[C]], [[COPY1]]
91 ; RV64I-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY1]], [[C1]]
92 ; RV64I-NEXT: [[SLLW:%[0-9]+]]:_(s64) = G_SLLW [[COPY]], [[AND]]
93 ; RV64I-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[SUB]], [[C1]]
94 ; RV64I-NEXT: [[SRLW:%[0-9]+]]:_(s64) = G_SRLW [[COPY]], [[AND1]]
95 ; RV64I-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[SLLW]], [[SRLW]]
96 ; RV64I-NEXT: $x10 = COPY [[OR]](s64)
97 ; RV64I-NEXT: PseudoRET implicit $x10
99 ; RV64ZBB_OR_RV64ZBKB-LABEL: name: rotl_i32
100 ; RV64ZBB_OR_RV64ZBKB: liveins: $x10, $x11
101 ; RV64ZBB_OR_RV64ZBKB-NEXT: {{ $}}
102 ; RV64ZBB_OR_RV64ZBKB-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
103 ; RV64ZBB_OR_RV64ZBKB-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
104 ; RV64ZBB_OR_RV64ZBKB-NEXT: [[ROLW:%[0-9]+]]:_(s64) = G_ROLW [[COPY]], [[COPY1]]
105 ; RV64ZBB_OR_RV64ZBKB-NEXT: $x10 = COPY [[ROLW]](s64)
106 ; RV64ZBB_OR_RV64ZBKB-NEXT: PseudoRET implicit $x10
107 %2:_(s64) = COPY $x10
108 %0:_(s32) = G_TRUNC %2(s64)
109 %3:_(s64) = COPY $x11
110 %1:_(s32) = G_TRUNC %3(s64)
111 %4:_(s32) = G_ROTL %0, %1(s32)
112 %5:_(s64) = G_ANYEXT %4(s32)
114 PseudoRET implicit $x10
123 ; RV64I-LABEL: name: rotl_i64
124 ; RV64I: liveins: $x10, $x11
126 ; RV64I-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
127 ; RV64I-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
128 ; RV64I-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
129 ; RV64I-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 63
130 ; RV64I-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[C]], [[COPY1]]
131 ; RV64I-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY1]], [[C1]]
132 ; RV64I-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY]], [[AND]](s64)
133 ; RV64I-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[SUB]], [[C1]]
134 ; RV64I-NEXT: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[COPY]], [[AND1]](s64)
135 ; RV64I-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[SHL]], [[LSHR]]
136 ; RV64I-NEXT: $x10 = COPY [[OR]](s64)
137 ; RV64I-NEXT: PseudoRET implicit $x10
139 ; RV64ZBB_OR_RV64ZBKB-LABEL: name: rotl_i64
140 ; RV64ZBB_OR_RV64ZBKB: liveins: $x10, $x11
141 ; RV64ZBB_OR_RV64ZBKB-NEXT: {{ $}}
142 ; RV64ZBB_OR_RV64ZBKB-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
143 ; RV64ZBB_OR_RV64ZBKB-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
144 ; RV64ZBB_OR_RV64ZBKB-NEXT: [[ROTL:%[0-9]+]]:_(s64) = G_ROTL [[COPY]], [[COPY1]](s64)
145 ; RV64ZBB_OR_RV64ZBKB-NEXT: $x10 = COPY [[ROTL]](s64)
146 ; RV64ZBB_OR_RV64ZBKB-NEXT: PseudoRET implicit $x10
147 %0:_(s64) = COPY $x10
148 %1:_(s64) = COPY $x11
149 %2:_(s64) = G_ROTL %0, %1(s64)
151 PseudoRET implicit $x10
160 ; CHECK-LABEL: name: rotr_i8
161 ; CHECK: liveins: $x10, $x11
163 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
164 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
165 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
166 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 7
167 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[C]], [[COPY1]]
168 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY1]], [[C1]]
169 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 255
170 ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[AND]], [[C2]]
171 ; CHECK-NEXT: [[AND2:%[0-9]+]]:_(s64) = G_AND [[COPY]], [[C2]]
172 ; CHECK-NEXT: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[AND2]], [[AND1]](s64)
173 ; CHECK-NEXT: [[AND3:%[0-9]+]]:_(s64) = G_AND [[SUB]], [[C1]]
174 ; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY]], [[AND3]](s64)
175 ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[LSHR]], [[SHL]]
176 ; CHECK-NEXT: $x10 = COPY [[OR]](s64)
177 ; CHECK-NEXT: PseudoRET implicit $x10
178 %2:_(s64) = COPY $x10
179 %0:_(s8) = G_TRUNC %2(s64)
180 %3:_(s64) = COPY $x11
181 %1:_(s8) = G_TRUNC %3(s64)
182 %4:_(s8) = G_ROTR %0, %1(s8)
183 %5:_(s64) = G_ANYEXT %4(s8)
185 PseudoRET implicit $x10
194 ; CHECK-LABEL: name: rotr_i16
195 ; CHECK: liveins: $x10, $x11
197 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
198 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
199 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
200 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 15
201 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[C]], [[COPY1]]
202 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY1]], [[C1]]
203 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 65535
204 ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[AND]], [[C2]]
205 ; CHECK-NEXT: [[AND2:%[0-9]+]]:_(s64) = G_AND [[COPY]], [[C2]]
206 ; CHECK-NEXT: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[AND2]], [[AND1]](s64)
207 ; CHECK-NEXT: [[AND3:%[0-9]+]]:_(s64) = G_AND [[SUB]], [[C1]]
208 ; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY]], [[AND3]](s64)
209 ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[LSHR]], [[SHL]]
210 ; CHECK-NEXT: $x10 = COPY [[OR]](s64)
211 ; CHECK-NEXT: PseudoRET implicit $x10
212 %2:_(s64) = COPY $x10
213 %0:_(s16) = G_TRUNC %2(s64)
214 %3:_(s64) = COPY $x11
215 %1:_(s16) = G_TRUNC %3(s64)
216 %4:_(s16) = G_ROTR %0, %1(s16)
217 %5:_(s64) = G_ANYEXT %4(s16)
219 PseudoRET implicit $x10
228 ; RV64I-LABEL: name: rotr_i32
229 ; RV64I: liveins: $x10, $x11
231 ; RV64I-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
232 ; RV64I-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
233 ; RV64I-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
234 ; RV64I-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 31
235 ; RV64I-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[C]], [[COPY1]]
236 ; RV64I-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY1]], [[C1]]
237 ; RV64I-NEXT: [[SRLW:%[0-9]+]]:_(s64) = G_SRLW [[COPY]], [[AND]]
238 ; RV64I-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[SUB]], [[C1]]
239 ; RV64I-NEXT: [[SLLW:%[0-9]+]]:_(s64) = G_SLLW [[COPY]], [[AND1]]
240 ; RV64I-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[SRLW]], [[SLLW]]
241 ; RV64I-NEXT: $x10 = COPY [[OR]](s64)
242 ; RV64I-NEXT: PseudoRET implicit $x10
244 ; RV64ZBB_OR_RV64ZBKB-LABEL: name: rotr_i32
245 ; RV64ZBB_OR_RV64ZBKB: liveins: $x10, $x11
246 ; RV64ZBB_OR_RV64ZBKB-NEXT: {{ $}}
247 ; RV64ZBB_OR_RV64ZBKB-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
248 ; RV64ZBB_OR_RV64ZBKB-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
249 ; RV64ZBB_OR_RV64ZBKB-NEXT: [[RORW:%[0-9]+]]:_(s64) = G_RORW [[COPY]], [[COPY1]]
250 ; RV64ZBB_OR_RV64ZBKB-NEXT: $x10 = COPY [[RORW]](s64)
251 ; RV64ZBB_OR_RV64ZBKB-NEXT: PseudoRET implicit $x10
252 %2:_(s64) = COPY $x10
253 %0:_(s32) = G_TRUNC %2(s64)
254 %3:_(s64) = COPY $x11
255 %1:_(s32) = G_TRUNC %3(s64)
256 %4:_(s32) = G_ROTR %0, %1(s32)
257 %5:_(s64) = G_ANYEXT %4(s32)
259 PseudoRET implicit $x10
268 ; RV64I-LABEL: name: rotr_i64
269 ; RV64I: liveins: $x10, $x11
271 ; RV64I-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
272 ; RV64I-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
273 ; RV64I-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
274 ; RV64I-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 63
275 ; RV64I-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[C]], [[COPY1]]
276 ; RV64I-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY1]], [[C1]]
277 ; RV64I-NEXT: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[COPY]], [[AND]](s64)
278 ; RV64I-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[SUB]], [[C1]]
279 ; RV64I-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY]], [[AND1]](s64)
280 ; RV64I-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[LSHR]], [[SHL]]
281 ; RV64I-NEXT: $x10 = COPY [[OR]](s64)
282 ; RV64I-NEXT: PseudoRET implicit $x10
284 ; RV64ZBB_OR_RV64ZBKB-LABEL: name: rotr_i64
285 ; RV64ZBB_OR_RV64ZBKB: liveins: $x10, $x11
286 ; RV64ZBB_OR_RV64ZBKB-NEXT: {{ $}}
287 ; RV64ZBB_OR_RV64ZBKB-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
288 ; RV64ZBB_OR_RV64ZBKB-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
289 ; RV64ZBB_OR_RV64ZBKB-NEXT: [[ROTR:%[0-9]+]]:_(s64) = G_ROTR [[COPY]], [[COPY1]](s64)
290 ; RV64ZBB_OR_RV64ZBKB-NEXT: $x10 = COPY [[ROTR]](s64)
291 ; RV64ZBB_OR_RV64ZBKB-NEXT: PseudoRET implicit $x10
292 %0:_(s64) = COPY $x10
293 %1:_(s64) = COPY $x11
294 %2:_(s64) = G_ROTR %0, %1(s64)
296 PseudoRET implicit $x10