66; RUN: llc -mtriple=riscv32 -mattr=+zbb,+zbs -verify-machineinstrs < %s \
77; RUN: | FileCheck %s --check-prefixes=CHECK,RV32,ZBS
88; RUN: llc -mtriple=riscv64 -mattr=+zbb,+zbs -verify-machineinstrs < %s \
9- ; RUN: | FileCheck %s --check-prefixes=CHECK,RV64,ZBS
9+ ; RUN: | FileCheck %s --check-prefixes=CHECK,RV64,ZBS,ZBS64
1010
1111define i32 @and0xabcdefff (i32 %x ) {
1212; CHECK-LABEL: and0xabcdefff:
@@ -301,16 +301,16 @@ define i64 @andimm64(i64 %x) {
301301 ret i64 %and
302302}
303303
304- define i64 @andimm64srli (i64 %x ) {
305- ; RV32-LABEL: andimm64srli :
304+ define i64 @orimm64srli (i64 %x ) {
305+ ; RV32-LABEL: orimm64srli :
306306; RV32: # %bb.0:
307307; RV32-NEXT: lui a2, 1040384
308308; RV32-NEXT: orn a0, a0, a2
309309; RV32-NEXT: lui a2, 917504
310310; RV32-NEXT: or a1, a1, a2
311311; RV32-NEXT: ret
312312;
313- ; RV64-LABEL: andimm64srli :
313+ ; RV64-LABEL: orimm64srli :
314314; RV64: # %bb.0:
315315; RV64-NEXT: lui a1, 983040
316316; RV64-NEXT: srli a1, a1, 3
@@ -319,3 +319,48 @@ define i64 @andimm64srli(i64 %x) {
319319 %or = or i64 %x , -2305843009180139521
320320 ret i64 %or
321321}
322+
323+ define i64 @andimm64srli (i64 %x ) {
324+ ; RV32-LABEL: andimm64srli:
325+ ; RV32: # %bb.0:
326+ ; RV32-NEXT: lui a2, 1044480
327+ ; RV32-NEXT: and a1, a1, a2
328+ ; RV32-NEXT: andi a0, a0, 255
329+ ; RV32-NEXT: ret
330+ ;
331+ ; RV64-LABEL: andimm64srli:
332+ ; RV64: # %bb.0:
333+ ; RV64-NEXT: li a1, -1
334+ ; RV64-NEXT: slli a1, a1, 56
335+ ; RV64-NEXT: addi a1, a1, 255
336+ ; RV64-NEXT: and a0, a0, a1
337+ ; RV64-NEXT: ret
338+ %and = and i64 %x , -72057594037927681
339+ ret i64 %and
340+ }
341+
342+ define i64 @andimm64srli2 (i64 %x ) {
343+ ; RV32-LABEL: andimm64srli2:
344+ ; RV32: # %bb.0:
345+ ; RV32-NEXT: lui a2, 524288
346+ ; RV32-NEXT: and a1, a1, a2
347+ ; RV32-NEXT: andi a0, a0, 2047
348+ ; RV32-NEXT: ret
349+ ;
350+ ; NOZBS64-LABEL: andimm64srli2:
351+ ; NOZBS64: # %bb.0:
352+ ; NOZBS64-NEXT: li a1, -1
353+ ; NOZBS64-NEXT: slli a1, a1, 63
354+ ; NOZBS64-NEXT: addi a1, a1, 2047
355+ ; NOZBS64-NEXT: and a0, a0, a1
356+ ; NOZBS64-NEXT: ret
357+ ;
358+ ; ZBS64-LABEL: andimm64srli2:
359+ ; ZBS64: # %bb.0:
360+ ; ZBS64-NEXT: li a1, 2047
361+ ; ZBS64-NEXT: bseti a1, a1, 63
362+ ; ZBS64-NEXT: and a0, a0, a1
363+ ; ZBS64-NEXT: ret
364+ %and = and i64 %x , -9223372036854773761
365+ ret i64 %and
366+ }
0 commit comments