diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h --- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h +++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h @@ -128,7 +128,10 @@ bool selectVSplat(SDValue N, SDValue &SplatVal); bool selectVSplatSimm5(SDValue N, SDValue &SplatVal); - bool selectVSplatUimm5(SDValue N, SDValue &SplatVal); + bool selectVSplatUimm(SDValue N, unsigned Bits, SDValue &SplatVal); + template bool selectVSplatUimmBits(SDValue N, SDValue &Val) { + return selectVSplatUimm(N, Bits, Val); + } bool selectVSplatSimm5Plus1(SDValue N, SDValue &SplatVal); bool selectVSplatSimm5Plus1NonZero(SDValue N, SDValue &SplatVal); bool selectFPImm(SDValue N, SDValue &Imm); diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp --- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp @@ -3003,7 +3003,7 @@ }); } -bool RISCVDAGToDAGISel::selectVSplatUimm5(SDValue N, SDValue &SplatVal) { +bool RISCVDAGToDAGISel::selectVSplatUimm(SDValue N, unsigned Bits, SDValue &SplatVal) { if (N.getOpcode() != RISCVISD::VMV_V_X_VL || !N.getOperand(0).isUndef() || !isa(N.getOperand(1))) return false; @@ -3011,7 +3011,7 @@ int64_t SplatImm = cast(N.getOperand(1))->getSExtValue(); - if (!isUInt<5>(SplatImm)) + if (!isUIntN(Bits, SplatImm)) return false; SplatVal = diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -679,8 +679,6 @@ setOperationAction({ISD::SMIN, ISD::SMAX, ISD::UMIN, ISD::UMAX}, VT, Legal); - setOperationAction({ISD::ROTL, ISD::ROTR}, VT, Expand); - setOperationAction({ISD::VP_FSHL, ISD::VP_FSHR}, VT, Expand); // Custom-lower extensions and truncations from/to mask types. @@ -770,6 +768,8 @@ ISD::VP_CTLZ_ZERO_UNDEF, ISD::VP_CTTZ_ZERO_UNDEF}, VT, Custom); } + + setOperationAction({ISD::ROTL, ISD::ROTR}, VT, Expand); } } diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.td b/llvm/lib/Target/RISCV/RISCVInstrInfo.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td @@ -450,6 +450,12 @@ N->getValueType(0)); }]>; +// Return an immediate subtracted from 64. +def ImmSubFrom64 : SDNodeXFormgetTargetConstant(64 - N->getZExtValue(), SDLoc(N), + N->getValueType(0)); +}]>; + // Check if (add r, imm) can be optimized to (ADDI (ADDI r, imm0), imm1), // in which imm = imm0 + imm1 and both imm0 and imm1 are simm12. We make imm0 // as large as possible and imm1 as small as possible so that we might be able diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td @@ -570,7 +570,8 @@ // Give explicit Complexity to prefer simm5/uimm5. def SplatPat : ComplexPattern; def SplatPat_simm5 : ComplexPattern; -def SplatPat_uimm5 : ComplexPattern; +def SplatPat_uimm5 : ComplexPattern", [], [], 2>; +def SplatPat_uimm6 : ComplexPattern", [], [], 2>; def SplatPat_simm5_plus1 : ComplexPattern; def SplatPat_simm5_plus1_nonzero diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td b/llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td @@ -200,6 +200,9 @@ defm PseudoVCTZ : VPseudoUnaryV_V; defm PseudoVCPOP : VPseudoUnaryV_V; +defm PseudoVROL : VPseudoVALU_VV_VX; +defm PseudoVROR : VPseudoVALU_VV_VX_VI; + //===----------------------------------------------------------------------===// // SDNode patterns //===----------------------------------------------------------------------===// @@ -251,6 +254,23 @@ defm : VPatUnarySDNode_V; defm : VPatUnarySDNode_V; +defm : VPatBinarySDNode_VV_VX; +// Although there is no vrol.vi, an immediate rotate left can be achieved by +// negating the immediate in vror.vi +foreach vti = AllIntegerVectors in { + let Predicates = !listconcat([HasStdExtZvbb], + GetVTypePredicates.Predicates) in { + def : Pat<(vti.Vector (rotl vti.RegClass:$rs2, + (vti.Vector (SplatPat_uimm6 uimm6:$rs1)))), + (!cast("PseudoVROR_VI_"#vti.LMul.MX) + (vti.Vector (IMPLICIT_DEF)), + vti.RegClass:$rs2, + (ImmSubFrom64 uimm6:$rs1), + vti.AVL, vti.Log2SEW, TA_MA)>; + } +} +defm : VPatBinarySDNode_VV_VX_VI; + //===----------------------------------------------------------------------===// // VL patterns //===----------------------------------------------------------------------===// diff --git a/llvm/test/CodeGen/RISCV/rvv/vrol-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vrol-sdnode.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv/vrol-sdnode.ll @@ -0,0 +1,1233 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2 +; RUN: llc -mtriple=riscv32 -mattr=+v -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,CHECK-RV32 +; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,CHECK-RV64 +; RUN: llc -mtriple=riscv32 -mattr=+v,+experimental-zvbb -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK-ZVBB,CHECK-ZVBB32 +; RUN: llc -mtriple=riscv64 -mattr=+v,+experimental-zvbb -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK-ZVBB,CHECK-ZVBB64 + +declare @llvm.fshl.nxv1i8(, , ) + +define @vrol_vv_nxv1i8( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv1i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, mf8, ta, ma +; CHECK-NEXT: vand.vi v10, v9, 7 +; CHECK-NEXT: vsll.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 7 +; CHECK-NEXT: vsrl.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv1i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, mf8, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v9 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv1i8( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv1i8( %a, i8 %b) { +; CHECK-LABEL: vrol_vx_nxv1i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, mf8, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vand.vi v10, v9, 7 +; CHECK-NEXT: vsll.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 7 +; CHECK-NEXT: vsrl.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vx_nxv1i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e8, mf8, ta, ma +; CHECK-ZVBB-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i8 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv1i8( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv2i8(, , ) + +define @vrol_vv_nxv2i8( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv2i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, mf4, ta, ma +; CHECK-NEXT: vand.vi v10, v9, 7 +; CHECK-NEXT: vsll.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 7 +; CHECK-NEXT: vsrl.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv2i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, mf4, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v9 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv2i8( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv2i8( %a, i8 %b) { +; CHECK-LABEL: vrol_vx_nxv2i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vand.vi v10, v9, 7 +; CHECK-NEXT: vsll.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 7 +; CHECK-NEXT: vsrl.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vx_nxv2i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e8, mf4, ta, ma +; CHECK-ZVBB-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i8 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv2i8( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv4i8(, , ) + +define @vrol_vv_nxv4i8( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv4i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma +; CHECK-NEXT: vand.vi v10, v9, 7 +; CHECK-NEXT: vsll.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 7 +; CHECK-NEXT: vsrl.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv4i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, mf2, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v9 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv4i8( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv4i8( %a, i8 %b) { +; CHECK-LABEL: vrol_vx_nxv4i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vand.vi v10, v9, 7 +; CHECK-NEXT: vsll.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 7 +; CHECK-NEXT: vsrl.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vx_nxv4i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e8, mf2, ta, ma +; CHECK-ZVBB-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i8 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv4i8( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv8i8(, , ) + +define @vrol_vv_nxv8i8( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv8i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma +; CHECK-NEXT: vand.vi v10, v9, 7 +; CHECK-NEXT: vsll.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 7 +; CHECK-NEXT: vsrl.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv8i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, m1, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v9 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv8i8( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv8i8( %a, i8 %b) { +; CHECK-LABEL: vrol_vx_nxv8i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vand.vi v10, v9, 7 +; CHECK-NEXT: vsll.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 7 +; CHECK-NEXT: vsrl.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vx_nxv8i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e8, m1, ta, ma +; CHECK-ZVBB-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i8 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv8i8( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv16i8(, , ) + +define @vrol_vv_nxv16i8( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv16i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma +; CHECK-NEXT: vand.vi v12, v10, 7 +; CHECK-NEXT: vsll.vv v12, v8, v12 +; CHECK-NEXT: vrsub.vi v10, v10, 0 +; CHECK-NEXT: vand.vi v10, v10, 7 +; CHECK-NEXT: vsrl.vv v8, v8, v10 +; CHECK-NEXT: vor.vv v8, v12, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv16i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, m2, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v10 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv16i8( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv16i8( %a, i8 %b) { +; CHECK-LABEL: vrol_vx_nxv16i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, m2, ta, ma +; CHECK-NEXT: vmv.v.x v10, a0 +; CHECK-NEXT: vand.vi v12, v10, 7 +; CHECK-NEXT: vsll.vv v12, v8, v12 +; CHECK-NEXT: vrsub.vi v10, v10, 0 +; CHECK-NEXT: vand.vi v10, v10, 7 +; CHECK-NEXT: vsrl.vv v8, v8, v10 +; CHECK-NEXT: vor.vv v8, v12, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vx_nxv16i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e8, m2, ta, ma +; CHECK-ZVBB-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i8 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv16i8( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv32i8(, , ) + +define @vrol_vv_nxv32i8( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv32i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, m4, ta, ma +; CHECK-NEXT: vand.vi v16, v12, 7 +; CHECK-NEXT: vsll.vv v16, v8, v16 +; CHECK-NEXT: vrsub.vi v12, v12, 0 +; CHECK-NEXT: vand.vi v12, v12, 7 +; CHECK-NEXT: vsrl.vv v8, v8, v12 +; CHECK-NEXT: vor.vv v8, v16, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv32i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, m4, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v12 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv32i8( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv32i8( %a, i8 %b) { +; CHECK-LABEL: vrol_vx_nxv32i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, m4, ta, ma +; CHECK-NEXT: vmv.v.x v12, a0 +; CHECK-NEXT: vand.vi v16, v12, 7 +; CHECK-NEXT: vsll.vv v16, v8, v16 +; CHECK-NEXT: vrsub.vi v12, v12, 0 +; CHECK-NEXT: vand.vi v12, v12, 7 +; CHECK-NEXT: vsrl.vv v8, v8, v12 +; CHECK-NEXT: vor.vv v8, v16, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vx_nxv32i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e8, m4, ta, ma +; CHECK-ZVBB-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i8 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv32i8( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv64i8(, , ) + +define @vrol_vv_nxv64i8( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv64i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, m8, ta, ma +; CHECK-NEXT: vand.vi v24, v16, 7 +; CHECK-NEXT: vsll.vv v24, v8, v24 +; CHECK-NEXT: vrsub.vi v16, v16, 0 +; CHECK-NEXT: vand.vi v16, v16, 7 +; CHECK-NEXT: vsrl.vv v8, v8, v16 +; CHECK-NEXT: vor.vv v8, v24, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv64i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, m8, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v16 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv64i8( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv64i8( %a, i8 %b) { +; CHECK-LABEL: vrol_vx_nxv64i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, m8, ta, ma +; CHECK-NEXT: vmv.v.x v16, a0 +; CHECK-NEXT: vand.vi v24, v16, 7 +; CHECK-NEXT: vsll.vv v24, v8, v24 +; CHECK-NEXT: vrsub.vi v16, v16, 0 +; CHECK-NEXT: vand.vi v16, v16, 7 +; CHECK-NEXT: vsrl.vv v8, v8, v16 +; CHECK-NEXT: vor.vv v8, v24, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vx_nxv64i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e8, m8, ta, ma +; CHECK-ZVBB-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i8 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv64i8( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv1i16(, , ) + +define @vrol_vv_nxv1i16( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv1i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, ma +; CHECK-NEXT: vand.vi v10, v9, 15 +; CHECK-NEXT: vsll.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 15 +; CHECK-NEXT: vsrl.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv1i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, mf4, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v9 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv1i16( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv1i16( %a, i16 %b) { +; CHECK-LABEL: vrol_vx_nxv1i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, mf4, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vand.vi v10, v9, 15 +; CHECK-NEXT: vsll.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 15 +; CHECK-NEXT: vsrl.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vx_nxv1i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e16, mf4, ta, ma +; CHECK-ZVBB-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i16 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv1i16( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv2i16(, , ) + +define @vrol_vv_nxv2i16( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv2i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma +; CHECK-NEXT: vand.vi v10, v9, 15 +; CHECK-NEXT: vsll.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 15 +; CHECK-NEXT: vsrl.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv2i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, mf2, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v9 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv2i16( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv2i16( %a, i16 %b) { +; CHECK-LABEL: vrol_vx_nxv2i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vand.vi v10, v9, 15 +; CHECK-NEXT: vsll.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 15 +; CHECK-NEXT: vsrl.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vx_nxv2i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e16, mf2, ta, ma +; CHECK-ZVBB-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i16 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv2i16( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv4i16(, , ) + +define @vrol_vv_nxv4i16( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv4i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma +; CHECK-NEXT: vand.vi v10, v9, 15 +; CHECK-NEXT: vsll.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 15 +; CHECK-NEXT: vsrl.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv4i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, m1, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v9 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv4i16( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv4i16( %a, i16 %b) { +; CHECK-LABEL: vrol_vx_nxv4i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vand.vi v10, v9, 15 +; CHECK-NEXT: vsll.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 15 +; CHECK-NEXT: vsrl.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vx_nxv4i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e16, m1, ta, ma +; CHECK-ZVBB-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i16 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv4i16( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv8i16(, , ) + +define @vrol_vv_nxv8i16( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv8i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma +; CHECK-NEXT: vand.vi v12, v10, 15 +; CHECK-NEXT: vsll.vv v12, v8, v12 +; CHECK-NEXT: vrsub.vi v10, v10, 0 +; CHECK-NEXT: vand.vi v10, v10, 15 +; CHECK-NEXT: vsrl.vv v8, v8, v10 +; CHECK-NEXT: vor.vv v8, v12, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv8i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, m2, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v10 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv8i16( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv8i16( %a, i16 %b) { +; CHECK-LABEL: vrol_vx_nxv8i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma +; CHECK-NEXT: vmv.v.x v10, a0 +; CHECK-NEXT: vand.vi v12, v10, 15 +; CHECK-NEXT: vsll.vv v12, v8, v12 +; CHECK-NEXT: vrsub.vi v10, v10, 0 +; CHECK-NEXT: vand.vi v10, v10, 15 +; CHECK-NEXT: vsrl.vv v8, v8, v10 +; CHECK-NEXT: vor.vv v8, v12, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vx_nxv8i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e16, m2, ta, ma +; CHECK-ZVBB-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i16 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv8i16( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv16i16(, , ) + +define @vrol_vv_nxv16i16( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv16i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, ma +; CHECK-NEXT: vand.vi v16, v12, 15 +; CHECK-NEXT: vsll.vv v16, v8, v16 +; CHECK-NEXT: vrsub.vi v12, v12, 0 +; CHECK-NEXT: vand.vi v12, v12, 15 +; CHECK-NEXT: vsrl.vv v8, v8, v12 +; CHECK-NEXT: vor.vv v8, v16, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv16i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, m4, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v12 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv16i16( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv16i16( %a, i16 %b) { +; CHECK-LABEL: vrol_vx_nxv16i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, m4, ta, ma +; CHECK-NEXT: vmv.v.x v12, a0 +; CHECK-NEXT: vand.vi v16, v12, 15 +; CHECK-NEXT: vsll.vv v16, v8, v16 +; CHECK-NEXT: vrsub.vi v12, v12, 0 +; CHECK-NEXT: vand.vi v12, v12, 15 +; CHECK-NEXT: vsrl.vv v8, v8, v12 +; CHECK-NEXT: vor.vv v8, v16, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vx_nxv16i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e16, m4, ta, ma +; CHECK-ZVBB-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i16 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv16i16( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv32i16(, , ) + +define @vrol_vv_nxv32i16( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv32i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, m8, ta, ma +; CHECK-NEXT: vand.vi v24, v16, 15 +; CHECK-NEXT: vsll.vv v24, v8, v24 +; CHECK-NEXT: vrsub.vi v16, v16, 0 +; CHECK-NEXT: vand.vi v16, v16, 15 +; CHECK-NEXT: vsrl.vv v8, v8, v16 +; CHECK-NEXT: vor.vv v8, v24, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv32i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, m8, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v16 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv32i16( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv32i16( %a, i16 %b) { +; CHECK-LABEL: vrol_vx_nxv32i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, m8, ta, ma +; CHECK-NEXT: vmv.v.x v16, a0 +; CHECK-NEXT: vand.vi v24, v16, 15 +; CHECK-NEXT: vsll.vv v24, v8, v24 +; CHECK-NEXT: vrsub.vi v16, v16, 0 +; CHECK-NEXT: vand.vi v16, v16, 15 +; CHECK-NEXT: vsrl.vv v8, v8, v16 +; CHECK-NEXT: vor.vv v8, v24, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vx_nxv32i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e16, m8, ta, ma +; CHECK-ZVBB-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i16 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv32i16( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv1i32(, , ) + +define @vrol_vv_nxv1i32( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv1i32: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 31 +; CHECK-NEXT: vsetvli a1, zero, e32, mf2, ta, ma +; CHECK-NEXT: vand.vx v10, v9, a0 +; CHECK-NEXT: vsll.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vx v9, v9, a0 +; CHECK-NEXT: vsrl.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv1i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e32, mf2, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v9 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv1i32( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv1i32( %a, i32 %b) { +; CHECK-RV32-LABEL: vrol_vx_nxv1i32: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: andi a1, a0, 31 +; CHECK-RV32-NEXT: vsetvli a2, zero, e32, mf2, ta, ma +; CHECK-RV32-NEXT: vsll.vx v9, v8, a1 +; CHECK-RV32-NEXT: neg a0, a0 +; CHECK-RV32-NEXT: andi a0, a0, 31 +; CHECK-RV32-NEXT: vsrl.vx v8, v8, a0 +; CHECK-RV32-NEXT: vor.vv v8, v9, v8 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vrol_vx_nxv1i32: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: vsetvli a1, zero, e32, mf2, ta, ma +; CHECK-RV64-NEXT: vmv.v.x v9, a0 +; CHECK-RV64-NEXT: li a0, 31 +; CHECK-RV64-NEXT: vand.vx v10, v9, a0 +; CHECK-RV64-NEXT: vsll.vv v10, v8, v10 +; CHECK-RV64-NEXT: vrsub.vi v9, v9, 0 +; CHECK-RV64-NEXT: vand.vx v9, v9, a0 +; CHECK-RV64-NEXT: vsrl.vv v8, v8, v9 +; CHECK-RV64-NEXT: vor.vv v8, v10, v8 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vx_nxv1i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e32, mf2, ta, ma +; CHECK-ZVBB-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i32 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv1i32( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv2i32(, , ) + +define @vrol_vv_nxv2i32( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv2i32: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 31 +; CHECK-NEXT: vsetvli a1, zero, e32, m1, ta, ma +; CHECK-NEXT: vand.vx v10, v9, a0 +; CHECK-NEXT: vsll.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vx v9, v9, a0 +; CHECK-NEXT: vsrl.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv2i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e32, m1, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v9 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv2i32( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv2i32( %a, i32 %b) { +; CHECK-RV32-LABEL: vrol_vx_nxv2i32: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: andi a1, a0, 31 +; CHECK-RV32-NEXT: vsetvli a2, zero, e32, m1, ta, ma +; CHECK-RV32-NEXT: vsll.vx v9, v8, a1 +; CHECK-RV32-NEXT: neg a0, a0 +; CHECK-RV32-NEXT: andi a0, a0, 31 +; CHECK-RV32-NEXT: vsrl.vx v8, v8, a0 +; CHECK-RV32-NEXT: vor.vv v8, v9, v8 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vrol_vx_nxv2i32: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: vsetvli a1, zero, e32, m1, ta, ma +; CHECK-RV64-NEXT: vmv.v.x v9, a0 +; CHECK-RV64-NEXT: li a0, 31 +; CHECK-RV64-NEXT: vand.vx v10, v9, a0 +; CHECK-RV64-NEXT: vsll.vv v10, v8, v10 +; CHECK-RV64-NEXT: vrsub.vi v9, v9, 0 +; CHECK-RV64-NEXT: vand.vx v9, v9, a0 +; CHECK-RV64-NEXT: vsrl.vv v8, v8, v9 +; CHECK-RV64-NEXT: vor.vv v8, v10, v8 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vx_nxv2i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e32, m1, ta, ma +; CHECK-ZVBB-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i32 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv2i32( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv4i32(, , ) + +define @vrol_vv_nxv4i32( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv4i32: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 31 +; CHECK-NEXT: vsetvli a1, zero, e32, m2, ta, ma +; CHECK-NEXT: vand.vx v12, v10, a0 +; CHECK-NEXT: vsll.vv v12, v8, v12 +; CHECK-NEXT: vrsub.vi v10, v10, 0 +; CHECK-NEXT: vand.vx v10, v10, a0 +; CHECK-NEXT: vsrl.vv v8, v8, v10 +; CHECK-NEXT: vor.vv v8, v12, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv4i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e32, m2, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v10 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv4i32( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv4i32( %a, i32 %b) { +; CHECK-RV32-LABEL: vrol_vx_nxv4i32: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: andi a1, a0, 31 +; CHECK-RV32-NEXT: vsetvli a2, zero, e32, m2, ta, ma +; CHECK-RV32-NEXT: vsll.vx v10, v8, a1 +; CHECK-RV32-NEXT: neg a0, a0 +; CHECK-RV32-NEXT: andi a0, a0, 31 +; CHECK-RV32-NEXT: vsrl.vx v8, v8, a0 +; CHECK-RV32-NEXT: vor.vv v8, v10, v8 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vrol_vx_nxv4i32: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: vsetvli a1, zero, e32, m2, ta, ma +; CHECK-RV64-NEXT: vmv.v.x v10, a0 +; CHECK-RV64-NEXT: li a0, 31 +; CHECK-RV64-NEXT: vand.vx v12, v10, a0 +; CHECK-RV64-NEXT: vsll.vv v12, v8, v12 +; CHECK-RV64-NEXT: vrsub.vi v10, v10, 0 +; CHECK-RV64-NEXT: vand.vx v10, v10, a0 +; CHECK-RV64-NEXT: vsrl.vv v8, v8, v10 +; CHECK-RV64-NEXT: vor.vv v8, v12, v8 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vx_nxv4i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e32, m2, ta, ma +; CHECK-ZVBB-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i32 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv4i32( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv8i32(, , ) + +define @vrol_vv_nxv8i32( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 31 +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, ma +; CHECK-NEXT: vand.vx v16, v12, a0 +; CHECK-NEXT: vsll.vv v16, v8, v16 +; CHECK-NEXT: vrsub.vi v12, v12, 0 +; CHECK-NEXT: vand.vx v12, v12, a0 +; CHECK-NEXT: vsrl.vv v8, v8, v12 +; CHECK-NEXT: vor.vv v8, v16, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv8i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e32, m4, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v12 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv8i32( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv8i32( %a, i32 %b) { +; CHECK-RV32-LABEL: vrol_vx_nxv8i32: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: andi a1, a0, 31 +; CHECK-RV32-NEXT: vsetvli a2, zero, e32, m4, ta, ma +; CHECK-RV32-NEXT: vsll.vx v12, v8, a1 +; CHECK-RV32-NEXT: neg a0, a0 +; CHECK-RV32-NEXT: andi a0, a0, 31 +; CHECK-RV32-NEXT: vsrl.vx v8, v8, a0 +; CHECK-RV32-NEXT: vor.vv v8, v12, v8 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vrol_vx_nxv8i32: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: vsetvli a1, zero, e32, m4, ta, ma +; CHECK-RV64-NEXT: vmv.v.x v12, a0 +; CHECK-RV64-NEXT: li a0, 31 +; CHECK-RV64-NEXT: vand.vx v16, v12, a0 +; CHECK-RV64-NEXT: vsll.vv v16, v8, v16 +; CHECK-RV64-NEXT: vrsub.vi v12, v12, 0 +; CHECK-RV64-NEXT: vand.vx v12, v12, a0 +; CHECK-RV64-NEXT: vsrl.vv v8, v8, v12 +; CHECK-RV64-NEXT: vor.vv v8, v16, v8 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vx_nxv8i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e32, m4, ta, ma +; CHECK-ZVBB-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i32 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv8i32( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv16i32(, , ) + +define @vrol_vv_nxv16i32( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv16i32: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 31 +; CHECK-NEXT: vsetvli a1, zero, e32, m8, ta, ma +; CHECK-NEXT: vand.vx v24, v16, a0 +; CHECK-NEXT: vsll.vv v24, v8, v24 +; CHECK-NEXT: vrsub.vi v16, v16, 0 +; CHECK-NEXT: vand.vx v16, v16, a0 +; CHECK-NEXT: vsrl.vv v8, v8, v16 +; CHECK-NEXT: vor.vv v8, v24, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv16i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e32, m8, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v16 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv16i32( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv16i32( %a, i32 %b) { +; CHECK-RV32-LABEL: vrol_vx_nxv16i32: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: andi a1, a0, 31 +; CHECK-RV32-NEXT: vsetvli a2, zero, e32, m8, ta, ma +; CHECK-RV32-NEXT: vsll.vx v16, v8, a1 +; CHECK-RV32-NEXT: neg a0, a0 +; CHECK-RV32-NEXT: andi a0, a0, 31 +; CHECK-RV32-NEXT: vsrl.vx v8, v8, a0 +; CHECK-RV32-NEXT: vor.vv v8, v16, v8 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vrol_vx_nxv16i32: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: vsetvli a1, zero, e32, m8, ta, ma +; CHECK-RV64-NEXT: vmv.v.x v16, a0 +; CHECK-RV64-NEXT: li a0, 31 +; CHECK-RV64-NEXT: vand.vx v24, v16, a0 +; CHECK-RV64-NEXT: vsll.vv v24, v8, v24 +; CHECK-RV64-NEXT: vrsub.vi v16, v16, 0 +; CHECK-RV64-NEXT: vand.vx v16, v16, a0 +; CHECK-RV64-NEXT: vsrl.vv v8, v8, v16 +; CHECK-RV64-NEXT: vor.vv v8, v24, v8 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vx_nxv16i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e32, m8, ta, ma +; CHECK-ZVBB-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i32 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv16i32( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv1i64(, , ) + +define @vrol_vv_nxv1i64( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv1i64: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 63 +; CHECK-NEXT: vsetvli a1, zero, e64, m1, ta, ma +; CHECK-NEXT: vand.vx v10, v9, a0 +; CHECK-NEXT: vsll.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vx v9, v9, a0 +; CHECK-NEXT: vsrl.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv1i64: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e64, m1, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v9 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv1i64( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv1i64( %a, i64 %b) { +; CHECK-RV32-LABEL: vrol_vx_nxv1i64: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: addi sp, sp, -16 +; CHECK-RV32-NEXT: .cfi_def_cfa_offset 16 +; CHECK-RV32-NEXT: sw a1, 12(sp) +; CHECK-RV32-NEXT: sw a0, 8(sp) +; CHECK-RV32-NEXT: addi a0, sp, 8 +; CHECK-RV32-NEXT: vsetvli a1, zero, e64, m1, ta, ma +; CHECK-RV32-NEXT: vlse64.v v9, (a0), zero +; CHECK-RV32-NEXT: li a0, 63 +; CHECK-RV32-NEXT: vand.vx v10, v9, a0 +; CHECK-RV32-NEXT: vsll.vv v10, v8, v10 +; CHECK-RV32-NEXT: vrsub.vi v9, v9, 0 +; CHECK-RV32-NEXT: vand.vx v9, v9, a0 +; CHECK-RV32-NEXT: vsrl.vv v8, v8, v9 +; CHECK-RV32-NEXT: vor.vv v8, v10, v8 +; CHECK-RV32-NEXT: addi sp, sp, 16 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vrol_vx_nxv1i64: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: andi a1, a0, 63 +; CHECK-RV64-NEXT: vsetvli a2, zero, e64, m1, ta, ma +; CHECK-RV64-NEXT: vsll.vx v9, v8, a1 +; CHECK-RV64-NEXT: negw a0, a0 +; CHECK-RV64-NEXT: andi a0, a0, 63 +; CHECK-RV64-NEXT: vsrl.vx v8, v8, a0 +; CHECK-RV64-NEXT: vor.vv v8, v9, v8 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB32-LABEL: vrol_vx_nxv1i64: +; CHECK-ZVBB32: # %bb.0: +; CHECK-ZVBB32-NEXT: addi sp, sp, -16 +; CHECK-ZVBB32-NEXT: .cfi_def_cfa_offset 16 +; CHECK-ZVBB32-NEXT: sw a1, 12(sp) +; CHECK-ZVBB32-NEXT: sw a0, 8(sp) +; CHECK-ZVBB32-NEXT: addi a0, sp, 8 +; CHECK-ZVBB32-NEXT: vsetvli a1, zero, e64, m1, ta, ma +; CHECK-ZVBB32-NEXT: vlse64.v v9, (a0), zero +; CHECK-ZVBB32-NEXT: vrol.vv v8, v8, v9 +; CHECK-ZVBB32-NEXT: addi sp, sp, 16 +; CHECK-ZVBB32-NEXT: ret +; +; CHECK-ZVBB64-LABEL: vrol_vx_nxv1i64: +; CHECK-ZVBB64: # %bb.0: +; CHECK-ZVBB64-NEXT: vsetvli a1, zero, e64, m1, ta, ma +; CHECK-ZVBB64-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB64-NEXT: ret + %b.head = insertelement poison, i64 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv1i64( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv2i64(, , ) + +define @vrol_vv_nxv2i64( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv2i64: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 63 +; CHECK-NEXT: vsetvli a1, zero, e64, m2, ta, ma +; CHECK-NEXT: vand.vx v12, v10, a0 +; CHECK-NEXT: vsll.vv v12, v8, v12 +; CHECK-NEXT: vrsub.vi v10, v10, 0 +; CHECK-NEXT: vand.vx v10, v10, a0 +; CHECK-NEXT: vsrl.vv v8, v8, v10 +; CHECK-NEXT: vor.vv v8, v12, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv2i64: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e64, m2, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v10 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv2i64( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv2i64( %a, i64 %b) { +; CHECK-RV32-LABEL: vrol_vx_nxv2i64: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: addi sp, sp, -16 +; CHECK-RV32-NEXT: .cfi_def_cfa_offset 16 +; CHECK-RV32-NEXT: sw a1, 12(sp) +; CHECK-RV32-NEXT: sw a0, 8(sp) +; CHECK-RV32-NEXT: addi a0, sp, 8 +; CHECK-RV32-NEXT: vsetvli a1, zero, e64, m2, ta, ma +; CHECK-RV32-NEXT: vlse64.v v10, (a0), zero +; CHECK-RV32-NEXT: li a0, 63 +; CHECK-RV32-NEXT: vand.vx v12, v10, a0 +; CHECK-RV32-NEXT: vsll.vv v12, v8, v12 +; CHECK-RV32-NEXT: vrsub.vi v10, v10, 0 +; CHECK-RV32-NEXT: vand.vx v10, v10, a0 +; CHECK-RV32-NEXT: vsrl.vv v8, v8, v10 +; CHECK-RV32-NEXT: vor.vv v8, v12, v8 +; CHECK-RV32-NEXT: addi sp, sp, 16 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vrol_vx_nxv2i64: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: andi a1, a0, 63 +; CHECK-RV64-NEXT: vsetvli a2, zero, e64, m2, ta, ma +; CHECK-RV64-NEXT: vsll.vx v10, v8, a1 +; CHECK-RV64-NEXT: negw a0, a0 +; CHECK-RV64-NEXT: andi a0, a0, 63 +; CHECK-RV64-NEXT: vsrl.vx v8, v8, a0 +; CHECK-RV64-NEXT: vor.vv v8, v10, v8 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB32-LABEL: vrol_vx_nxv2i64: +; CHECK-ZVBB32: # %bb.0: +; CHECK-ZVBB32-NEXT: addi sp, sp, -16 +; CHECK-ZVBB32-NEXT: .cfi_def_cfa_offset 16 +; CHECK-ZVBB32-NEXT: sw a1, 12(sp) +; CHECK-ZVBB32-NEXT: sw a0, 8(sp) +; CHECK-ZVBB32-NEXT: addi a0, sp, 8 +; CHECK-ZVBB32-NEXT: vsetvli a1, zero, e64, m2, ta, ma +; CHECK-ZVBB32-NEXT: vlse64.v v10, (a0), zero +; CHECK-ZVBB32-NEXT: vrol.vv v8, v8, v10 +; CHECK-ZVBB32-NEXT: addi sp, sp, 16 +; CHECK-ZVBB32-NEXT: ret +; +; CHECK-ZVBB64-LABEL: vrol_vx_nxv2i64: +; CHECK-ZVBB64: # %bb.0: +; CHECK-ZVBB64-NEXT: vsetvli a1, zero, e64, m2, ta, ma +; CHECK-ZVBB64-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB64-NEXT: ret + %b.head = insertelement poison, i64 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv2i64( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv4i64(, , ) + +define @vrol_vv_nxv4i64( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv4i64: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 63 +; CHECK-NEXT: vsetvli a1, zero, e64, m4, ta, ma +; CHECK-NEXT: vand.vx v16, v12, a0 +; CHECK-NEXT: vsll.vv v16, v8, v16 +; CHECK-NEXT: vrsub.vi v12, v12, 0 +; CHECK-NEXT: vand.vx v12, v12, a0 +; CHECK-NEXT: vsrl.vv v8, v8, v12 +; CHECK-NEXT: vor.vv v8, v16, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv4i64: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e64, m4, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v12 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv4i64( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv4i64( %a, i64 %b) { +; CHECK-RV32-LABEL: vrol_vx_nxv4i64: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: addi sp, sp, -16 +; CHECK-RV32-NEXT: .cfi_def_cfa_offset 16 +; CHECK-RV32-NEXT: sw a1, 12(sp) +; CHECK-RV32-NEXT: sw a0, 8(sp) +; CHECK-RV32-NEXT: addi a0, sp, 8 +; CHECK-RV32-NEXT: vsetvli a1, zero, e64, m4, ta, ma +; CHECK-RV32-NEXT: vlse64.v v12, (a0), zero +; CHECK-RV32-NEXT: li a0, 63 +; CHECK-RV32-NEXT: vand.vx v16, v12, a0 +; CHECK-RV32-NEXT: vsll.vv v16, v8, v16 +; CHECK-RV32-NEXT: vrsub.vi v12, v12, 0 +; CHECK-RV32-NEXT: vand.vx v12, v12, a0 +; CHECK-RV32-NEXT: vsrl.vv v8, v8, v12 +; CHECK-RV32-NEXT: vor.vv v8, v16, v8 +; CHECK-RV32-NEXT: addi sp, sp, 16 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vrol_vx_nxv4i64: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: andi a1, a0, 63 +; CHECK-RV64-NEXT: vsetvli a2, zero, e64, m4, ta, ma +; CHECK-RV64-NEXT: vsll.vx v12, v8, a1 +; CHECK-RV64-NEXT: negw a0, a0 +; CHECK-RV64-NEXT: andi a0, a0, 63 +; CHECK-RV64-NEXT: vsrl.vx v8, v8, a0 +; CHECK-RV64-NEXT: vor.vv v8, v12, v8 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB32-LABEL: vrol_vx_nxv4i64: +; CHECK-ZVBB32: # %bb.0: +; CHECK-ZVBB32-NEXT: addi sp, sp, -16 +; CHECK-ZVBB32-NEXT: .cfi_def_cfa_offset 16 +; CHECK-ZVBB32-NEXT: sw a1, 12(sp) +; CHECK-ZVBB32-NEXT: sw a0, 8(sp) +; CHECK-ZVBB32-NEXT: addi a0, sp, 8 +; CHECK-ZVBB32-NEXT: vsetvli a1, zero, e64, m4, ta, ma +; CHECK-ZVBB32-NEXT: vlse64.v v12, (a0), zero +; CHECK-ZVBB32-NEXT: vrol.vv v8, v8, v12 +; CHECK-ZVBB32-NEXT: addi sp, sp, 16 +; CHECK-ZVBB32-NEXT: ret +; +; CHECK-ZVBB64-LABEL: vrol_vx_nxv4i64: +; CHECK-ZVBB64: # %bb.0: +; CHECK-ZVBB64-NEXT: vsetvli a1, zero, e64, m4, ta, ma +; CHECK-ZVBB64-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB64-NEXT: ret + %b.head = insertelement poison, i64 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv4i64( %a, %a, %b.splat) + ret %x +} + +declare @llvm.fshl.nxv8i64(, , ) + +define @vrol_vv_nxv8i64( %a, %b) { +; CHECK-LABEL: vrol_vv_nxv8i64: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 63 +; CHECK-NEXT: vsetvli a1, zero, e64, m8, ta, ma +; CHECK-NEXT: vand.vx v24, v16, a0 +; CHECK-NEXT: vsll.vv v24, v8, v24 +; CHECK-NEXT: vrsub.vi v16, v16, 0 +; CHECK-NEXT: vand.vx v16, v16, a0 +; CHECK-NEXT: vsrl.vv v8, v8, v16 +; CHECK-NEXT: vor.vv v8, v24, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vrol_vv_nxv8i64: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e64, m8, ta, ma +; CHECK-ZVBB-NEXT: vrol.vv v8, v8, v16 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv8i64( %a, %a, %b) + ret %x +} + +define @vrol_vx_nxv8i64( %a, i64 %b) { +; CHECK-RV32-LABEL: vrol_vx_nxv8i64: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: addi sp, sp, -16 +; CHECK-RV32-NEXT: .cfi_def_cfa_offset 16 +; CHECK-RV32-NEXT: sw a1, 12(sp) +; CHECK-RV32-NEXT: sw a0, 8(sp) +; CHECK-RV32-NEXT: addi a0, sp, 8 +; CHECK-RV32-NEXT: vsetvli a1, zero, e64, m8, ta, ma +; CHECK-RV32-NEXT: vlse64.v v16, (a0), zero +; CHECK-RV32-NEXT: li a0, 63 +; CHECK-RV32-NEXT: vand.vx v24, v16, a0 +; CHECK-RV32-NEXT: vsll.vv v24, v8, v24 +; CHECK-RV32-NEXT: vrsub.vi v16, v16, 0 +; CHECK-RV32-NEXT: vand.vx v16, v16, a0 +; CHECK-RV32-NEXT: vsrl.vv v8, v8, v16 +; CHECK-RV32-NEXT: vor.vv v8, v24, v8 +; CHECK-RV32-NEXT: addi sp, sp, 16 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vrol_vx_nxv8i64: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: andi a1, a0, 63 +; CHECK-RV64-NEXT: vsetvli a2, zero, e64, m8, ta, ma +; CHECK-RV64-NEXT: vsll.vx v16, v8, a1 +; CHECK-RV64-NEXT: negw a0, a0 +; CHECK-RV64-NEXT: andi a0, a0, 63 +; CHECK-RV64-NEXT: vsrl.vx v8, v8, a0 +; CHECK-RV64-NEXT: vor.vv v8, v16, v8 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB32-LABEL: vrol_vx_nxv8i64: +; CHECK-ZVBB32: # %bb.0: +; CHECK-ZVBB32-NEXT: addi sp, sp, -16 +; CHECK-ZVBB32-NEXT: .cfi_def_cfa_offset 16 +; CHECK-ZVBB32-NEXT: sw a1, 12(sp) +; CHECK-ZVBB32-NEXT: sw a0, 8(sp) +; CHECK-ZVBB32-NEXT: addi a0, sp, 8 +; CHECK-ZVBB32-NEXT: vsetvli a1, zero, e64, m8, ta, ma +; CHECK-ZVBB32-NEXT: vlse64.v v16, (a0), zero +; CHECK-ZVBB32-NEXT: vrol.vv v8, v8, v16 +; CHECK-ZVBB32-NEXT: addi sp, sp, 16 +; CHECK-ZVBB32-NEXT: ret +; +; CHECK-ZVBB64-LABEL: vrol_vx_nxv8i64: +; CHECK-ZVBB64: # %bb.0: +; CHECK-ZVBB64-NEXT: vsetvli a1, zero, e64, m8, ta, ma +; CHECK-ZVBB64-NEXT: vrol.vx v8, v8, a0 +; CHECK-ZVBB64-NEXT: ret + %b.head = insertelement poison, i64 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshl.nxv8i64( %a, %a, %b.splat) + ret %x +} + diff --git a/llvm/test/CodeGen/RISCV/rvv/vror-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vror-sdnode.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv/vror-sdnode.ll @@ -0,0 +1,2167 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2 +; RUN: llc -mtriple=riscv32 -mattr=+v -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,CHECK-RV32 +; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,CHECK-RV64 +; RUN: llc -mtriple=riscv32 -mattr=+v,+experimental-zvbb -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK-ZVBB,CHECK-ZVBB32 +; RUN: llc -mtriple=riscv64 -mattr=+v,+experimental-zvbb -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK-ZVBB,CHECK-ZVBB64 + +declare @llvm.fshr.nxv1i8(, , ) +declare @llvm.fshl.nxv1i8(, , ) + +define @vror_vv_nxv1i8( %a, %b) { +; CHECK-LABEL: vror_vv_nxv1i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, mf8, ta, ma +; CHECK-NEXT: vand.vi v10, v9, 7 +; CHECK-NEXT: vsrl.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 7 +; CHECK-NEXT: vsll.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv1i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, mf8, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v9 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv1i8( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv1i8( %a, i8 %b) { +; CHECK-LABEL: vror_vx_nxv1i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, mf8, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vand.vi v10, v9, 7 +; CHECK-NEXT: vsrl.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 7 +; CHECK-NEXT: vsll.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vx_nxv1i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e8, mf8, ta, ma +; CHECK-ZVBB-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i8 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv1i8( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv1i8( %a) { +; CHECK-LABEL: vror_vi_nxv1i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, mf8, ta, ma +; CHECK-NEXT: vsll.vi v9, v8, 7 +; CHECK-NEXT: vsrl.vi v8, v8, 1 +; CHECK-NEXT: vor.vv v8, v8, v9 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv1i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, mf8, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv1i8( %a, %a, shufflevector( insertelement( poison, i8 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv1i8( %a) { +; CHECK-LABEL: vror_vi_rotl_nxv1i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, mf8, ta, ma +; CHECK-NEXT: vsrl.vi v9, v8, 7 +; CHECK-NEXT: vadd.vv v8, v8, v8 +; CHECK-NEXT: vor.vv v8, v8, v9 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv1i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, mf8, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv1i8( %a, %a, shufflevector( insertelement( poison, i8 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv2i8(, , ) +declare @llvm.fshl.nxv2i8(, , ) + +define @vror_vv_nxv2i8( %a, %b) { +; CHECK-LABEL: vror_vv_nxv2i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, mf4, ta, ma +; CHECK-NEXT: vand.vi v10, v9, 7 +; CHECK-NEXT: vsrl.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 7 +; CHECK-NEXT: vsll.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv2i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, mf4, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v9 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv2i8( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv2i8( %a, i8 %b) { +; CHECK-LABEL: vror_vx_nxv2i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vand.vi v10, v9, 7 +; CHECK-NEXT: vsrl.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 7 +; CHECK-NEXT: vsll.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vx_nxv2i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e8, mf4, ta, ma +; CHECK-ZVBB-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i8 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv2i8( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv2i8( %a) { +; CHECK-LABEL: vror_vi_nxv2i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, mf4, ta, ma +; CHECK-NEXT: vsll.vi v9, v8, 7 +; CHECK-NEXT: vsrl.vi v8, v8, 1 +; CHECK-NEXT: vor.vv v8, v8, v9 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv2i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, mf4, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv2i8( %a, %a, shufflevector( insertelement( poison, i8 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv2i8( %a) { +; CHECK-LABEL: vror_vi_rotl_nxv2i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, mf4, ta, ma +; CHECK-NEXT: vsrl.vi v9, v8, 7 +; CHECK-NEXT: vadd.vv v8, v8, v8 +; CHECK-NEXT: vor.vv v8, v8, v9 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv2i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, mf4, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv2i8( %a, %a, shufflevector( insertelement( poison, i8 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv4i8(, , ) +declare @llvm.fshl.nxv4i8(, , ) + +define @vror_vv_nxv4i8( %a, %b) { +; CHECK-LABEL: vror_vv_nxv4i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma +; CHECK-NEXT: vand.vi v10, v9, 7 +; CHECK-NEXT: vsrl.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 7 +; CHECK-NEXT: vsll.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv4i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, mf2, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v9 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv4i8( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv4i8( %a, i8 %b) { +; CHECK-LABEL: vror_vx_nxv4i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vand.vi v10, v9, 7 +; CHECK-NEXT: vsrl.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 7 +; CHECK-NEXT: vsll.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vx_nxv4i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e8, mf2, ta, ma +; CHECK-ZVBB-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i8 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv4i8( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv4i8( %a) { +; CHECK-LABEL: vror_vi_nxv4i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma +; CHECK-NEXT: vsll.vi v9, v8, 7 +; CHECK-NEXT: vsrl.vi v8, v8, 1 +; CHECK-NEXT: vor.vv v8, v8, v9 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv4i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, mf2, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv4i8( %a, %a, shufflevector( insertelement( poison, i8 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv4i8( %a) { +; CHECK-LABEL: vror_vi_rotl_nxv4i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma +; CHECK-NEXT: vsrl.vi v9, v8, 7 +; CHECK-NEXT: vadd.vv v8, v8, v8 +; CHECK-NEXT: vor.vv v8, v8, v9 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv4i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, mf2, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv4i8( %a, %a, shufflevector( insertelement( poison, i8 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv8i8(, , ) +declare @llvm.fshl.nxv8i8(, , ) + +define @vror_vv_nxv8i8( %a, %b) { +; CHECK-LABEL: vror_vv_nxv8i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma +; CHECK-NEXT: vand.vi v10, v9, 7 +; CHECK-NEXT: vsrl.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 7 +; CHECK-NEXT: vsll.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv8i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, m1, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v9 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv8i8( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv8i8( %a, i8 %b) { +; CHECK-LABEL: vror_vx_nxv8i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vand.vi v10, v9, 7 +; CHECK-NEXT: vsrl.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 7 +; CHECK-NEXT: vsll.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vx_nxv8i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e8, m1, ta, ma +; CHECK-ZVBB-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i8 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv8i8( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv8i8( %a) { +; CHECK-LABEL: vror_vi_nxv8i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma +; CHECK-NEXT: vsll.vi v9, v8, 7 +; CHECK-NEXT: vsrl.vi v8, v8, 1 +; CHECK-NEXT: vor.vv v8, v8, v9 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv8i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, m1, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv8i8( %a, %a, shufflevector( insertelement( poison, i8 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv8i8( %a) { +; CHECK-LABEL: vror_vi_rotl_nxv8i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma +; CHECK-NEXT: vsrl.vi v9, v8, 7 +; CHECK-NEXT: vadd.vv v8, v8, v8 +; CHECK-NEXT: vor.vv v8, v8, v9 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv8i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, m1, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv8i8( %a, %a, shufflevector( insertelement( poison, i8 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv16i8(, , ) +declare @llvm.fshl.nxv16i8(, , ) + +define @vror_vv_nxv16i8( %a, %b) { +; CHECK-LABEL: vror_vv_nxv16i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma +; CHECK-NEXT: vand.vi v12, v10, 7 +; CHECK-NEXT: vsrl.vv v12, v8, v12 +; CHECK-NEXT: vrsub.vi v10, v10, 0 +; CHECK-NEXT: vand.vi v10, v10, 7 +; CHECK-NEXT: vsll.vv v8, v8, v10 +; CHECK-NEXT: vor.vv v8, v12, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv16i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, m2, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v10 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv16i8( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv16i8( %a, i8 %b) { +; CHECK-LABEL: vror_vx_nxv16i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, m2, ta, ma +; CHECK-NEXT: vmv.v.x v10, a0 +; CHECK-NEXT: vand.vi v12, v10, 7 +; CHECK-NEXT: vsrl.vv v12, v8, v12 +; CHECK-NEXT: vrsub.vi v10, v10, 0 +; CHECK-NEXT: vand.vi v10, v10, 7 +; CHECK-NEXT: vsll.vv v8, v8, v10 +; CHECK-NEXT: vor.vv v8, v12, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vx_nxv16i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e8, m2, ta, ma +; CHECK-ZVBB-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i8 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv16i8( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv16i8( %a) { +; CHECK-LABEL: vror_vi_nxv16i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma +; CHECK-NEXT: vsll.vi v10, v8, 7 +; CHECK-NEXT: vsrl.vi v8, v8, 1 +; CHECK-NEXT: vor.vv v8, v8, v10 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv16i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, m2, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv16i8( %a, %a, shufflevector( insertelement( poison, i8 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv16i8( %a) { +; CHECK-LABEL: vror_vi_rotl_nxv16i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma +; CHECK-NEXT: vsrl.vi v10, v8, 7 +; CHECK-NEXT: vadd.vv v8, v8, v8 +; CHECK-NEXT: vor.vv v8, v8, v10 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv16i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, m2, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv16i8( %a, %a, shufflevector( insertelement( poison, i8 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv32i8(, , ) +declare @llvm.fshl.nxv32i8(, , ) + +define @vror_vv_nxv32i8( %a, %b) { +; CHECK-LABEL: vror_vv_nxv32i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, m4, ta, ma +; CHECK-NEXT: vand.vi v16, v12, 7 +; CHECK-NEXT: vsrl.vv v16, v8, v16 +; CHECK-NEXT: vrsub.vi v12, v12, 0 +; CHECK-NEXT: vand.vi v12, v12, 7 +; CHECK-NEXT: vsll.vv v8, v8, v12 +; CHECK-NEXT: vor.vv v8, v16, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv32i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, m4, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v12 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv32i8( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv32i8( %a, i8 %b) { +; CHECK-LABEL: vror_vx_nxv32i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, m4, ta, ma +; CHECK-NEXT: vmv.v.x v12, a0 +; CHECK-NEXT: vand.vi v16, v12, 7 +; CHECK-NEXT: vsrl.vv v16, v8, v16 +; CHECK-NEXT: vrsub.vi v12, v12, 0 +; CHECK-NEXT: vand.vi v12, v12, 7 +; CHECK-NEXT: vsll.vv v8, v8, v12 +; CHECK-NEXT: vor.vv v8, v16, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vx_nxv32i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e8, m4, ta, ma +; CHECK-ZVBB-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i8 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv32i8( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv32i8( %a) { +; CHECK-LABEL: vror_vi_nxv32i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, m4, ta, ma +; CHECK-NEXT: vsll.vi v12, v8, 7 +; CHECK-NEXT: vsrl.vi v8, v8, 1 +; CHECK-NEXT: vor.vv v8, v8, v12 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv32i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, m4, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv32i8( %a, %a, shufflevector( insertelement( poison, i8 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv32i8( %a) { +; CHECK-LABEL: vror_vi_rotl_nxv32i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, m4, ta, ma +; CHECK-NEXT: vsrl.vi v12, v8, 7 +; CHECK-NEXT: vadd.vv v8, v8, v8 +; CHECK-NEXT: vor.vv v8, v8, v12 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv32i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, m4, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv32i8( %a, %a, shufflevector( insertelement( poison, i8 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv64i8(, , ) +declare @llvm.fshl.nxv64i8(, , ) + +define @vror_vv_nxv64i8( %a, %b) { +; CHECK-LABEL: vror_vv_nxv64i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, m8, ta, ma +; CHECK-NEXT: vand.vi v24, v16, 7 +; CHECK-NEXT: vsrl.vv v24, v8, v24 +; CHECK-NEXT: vrsub.vi v16, v16, 0 +; CHECK-NEXT: vand.vi v16, v16, 7 +; CHECK-NEXT: vsll.vv v8, v8, v16 +; CHECK-NEXT: vor.vv v8, v24, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv64i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, m8, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v16 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv64i8( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv64i8( %a, i8 %b) { +; CHECK-LABEL: vror_vx_nxv64i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, m8, ta, ma +; CHECK-NEXT: vmv.v.x v16, a0 +; CHECK-NEXT: vand.vi v24, v16, 7 +; CHECK-NEXT: vsrl.vv v24, v8, v24 +; CHECK-NEXT: vrsub.vi v16, v16, 0 +; CHECK-NEXT: vand.vi v16, v16, 7 +; CHECK-NEXT: vsll.vv v8, v8, v16 +; CHECK-NEXT: vor.vv v8, v24, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vx_nxv64i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e8, m8, ta, ma +; CHECK-ZVBB-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i8 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv64i8( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv64i8( %a) { +; CHECK-LABEL: vror_vi_nxv64i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, m8, ta, ma +; CHECK-NEXT: vsll.vi v16, v8, 7 +; CHECK-NEXT: vsrl.vi v8, v8, 1 +; CHECK-NEXT: vor.vv v8, v8, v16 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv64i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, m8, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv64i8( %a, %a, shufflevector( insertelement( poison, i8 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv64i8( %a) { +; CHECK-LABEL: vror_vi_rotl_nxv64i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8, m8, ta, ma +; CHECK-NEXT: vsrl.vi v16, v8, 7 +; CHECK-NEXT: vadd.vv v8, v8, v8 +; CHECK-NEXT: vor.vv v8, v8, v16 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv64i8: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e8, m8, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv64i8( %a, %a, shufflevector( insertelement( poison, i8 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv1i16(, , ) +declare @llvm.fshl.nxv1i16(, , ) + +define @vror_vv_nxv1i16( %a, %b) { +; CHECK-LABEL: vror_vv_nxv1i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, ma +; CHECK-NEXT: vand.vi v10, v9, 15 +; CHECK-NEXT: vsrl.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 15 +; CHECK-NEXT: vsll.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv1i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, mf4, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v9 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv1i16( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv1i16( %a, i16 %b) { +; CHECK-LABEL: vror_vx_nxv1i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, mf4, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vand.vi v10, v9, 15 +; CHECK-NEXT: vsrl.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 15 +; CHECK-NEXT: vsll.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vx_nxv1i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e16, mf4, ta, ma +; CHECK-ZVBB-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i16 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv1i16( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv1i16( %a) { +; CHECK-LABEL: vror_vi_nxv1i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, ma +; CHECK-NEXT: vsll.vi v9, v8, 15 +; CHECK-NEXT: vsrl.vi v8, v8, 1 +; CHECK-NEXT: vor.vv v8, v8, v9 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv1i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, mf4, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv1i16( %a, %a, shufflevector( insertelement( poison, i16 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv1i16( %a) { +; CHECK-LABEL: vror_vi_rotl_nxv1i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, ma +; CHECK-NEXT: vsrl.vi v9, v8, 15 +; CHECK-NEXT: vadd.vv v8, v8, v8 +; CHECK-NEXT: vor.vv v8, v8, v9 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv1i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, mf4, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv1i16( %a, %a, shufflevector( insertelement( poison, i16 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv2i16(, , ) +declare @llvm.fshl.nxv2i16(, , ) + +define @vror_vv_nxv2i16( %a, %b) { +; CHECK-LABEL: vror_vv_nxv2i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma +; CHECK-NEXT: vand.vi v10, v9, 15 +; CHECK-NEXT: vsrl.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 15 +; CHECK-NEXT: vsll.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv2i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, mf2, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v9 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv2i16( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv2i16( %a, i16 %b) { +; CHECK-LABEL: vror_vx_nxv2i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vand.vi v10, v9, 15 +; CHECK-NEXT: vsrl.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 15 +; CHECK-NEXT: vsll.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vx_nxv2i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e16, mf2, ta, ma +; CHECK-ZVBB-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i16 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv2i16( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv2i16( %a) { +; CHECK-LABEL: vror_vi_nxv2i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma +; CHECK-NEXT: vsll.vi v9, v8, 15 +; CHECK-NEXT: vsrl.vi v8, v8, 1 +; CHECK-NEXT: vor.vv v8, v8, v9 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv2i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, mf2, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv2i16( %a, %a, shufflevector( insertelement( poison, i16 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv2i16( %a) { +; CHECK-LABEL: vror_vi_rotl_nxv2i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma +; CHECK-NEXT: vsrl.vi v9, v8, 15 +; CHECK-NEXT: vadd.vv v8, v8, v8 +; CHECK-NEXT: vor.vv v8, v8, v9 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv2i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, mf2, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv2i16( %a, %a, shufflevector( insertelement( poison, i16 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv4i16(, , ) +declare @llvm.fshl.nxv4i16(, , ) + +define @vror_vv_nxv4i16( %a, %b) { +; CHECK-LABEL: vror_vv_nxv4i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma +; CHECK-NEXT: vand.vi v10, v9, 15 +; CHECK-NEXT: vsrl.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 15 +; CHECK-NEXT: vsll.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv4i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, m1, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v9 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv4i16( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv4i16( %a, i16 %b) { +; CHECK-LABEL: vror_vx_nxv4i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vand.vi v10, v9, 15 +; CHECK-NEXT: vsrl.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vi v9, v9, 15 +; CHECK-NEXT: vsll.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vx_nxv4i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e16, m1, ta, ma +; CHECK-ZVBB-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i16 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv4i16( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv4i16( %a) { +; CHECK-LABEL: vror_vi_nxv4i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma +; CHECK-NEXT: vsll.vi v9, v8, 15 +; CHECK-NEXT: vsrl.vi v8, v8, 1 +; CHECK-NEXT: vor.vv v8, v8, v9 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv4i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, m1, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv4i16( %a, %a, shufflevector( insertelement( poison, i16 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv4i16( %a) { +; CHECK-LABEL: vror_vi_rotl_nxv4i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma +; CHECK-NEXT: vsrl.vi v9, v8, 15 +; CHECK-NEXT: vadd.vv v8, v8, v8 +; CHECK-NEXT: vor.vv v8, v8, v9 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv4i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, m1, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv4i16( %a, %a, shufflevector( insertelement( poison, i16 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv8i16(, , ) +declare @llvm.fshl.nxv8i16(, , ) + +define @vror_vv_nxv8i16( %a, %b) { +; CHECK-LABEL: vror_vv_nxv8i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma +; CHECK-NEXT: vand.vi v12, v10, 15 +; CHECK-NEXT: vsrl.vv v12, v8, v12 +; CHECK-NEXT: vrsub.vi v10, v10, 0 +; CHECK-NEXT: vand.vi v10, v10, 15 +; CHECK-NEXT: vsll.vv v8, v8, v10 +; CHECK-NEXT: vor.vv v8, v12, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv8i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, m2, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v10 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv8i16( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv8i16( %a, i16 %b) { +; CHECK-LABEL: vror_vx_nxv8i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma +; CHECK-NEXT: vmv.v.x v10, a0 +; CHECK-NEXT: vand.vi v12, v10, 15 +; CHECK-NEXT: vsrl.vv v12, v8, v12 +; CHECK-NEXT: vrsub.vi v10, v10, 0 +; CHECK-NEXT: vand.vi v10, v10, 15 +; CHECK-NEXT: vsll.vv v8, v8, v10 +; CHECK-NEXT: vor.vv v8, v12, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vx_nxv8i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e16, m2, ta, ma +; CHECK-ZVBB-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i16 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv8i16( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv8i16( %a) { +; CHECK-LABEL: vror_vi_nxv8i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma +; CHECK-NEXT: vsll.vi v10, v8, 15 +; CHECK-NEXT: vsrl.vi v8, v8, 1 +; CHECK-NEXT: vor.vv v8, v8, v10 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv8i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, m2, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv8i16( %a, %a, shufflevector( insertelement( poison, i16 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv8i16( %a) { +; CHECK-LABEL: vror_vi_rotl_nxv8i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma +; CHECK-NEXT: vsrl.vi v10, v8, 15 +; CHECK-NEXT: vadd.vv v8, v8, v8 +; CHECK-NEXT: vor.vv v8, v8, v10 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv8i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, m2, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv8i16( %a, %a, shufflevector( insertelement( poison, i16 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv16i16(, , ) +declare @llvm.fshl.nxv16i16(, , ) + +define @vror_vv_nxv16i16( %a, %b) { +; CHECK-LABEL: vror_vv_nxv16i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, ma +; CHECK-NEXT: vand.vi v16, v12, 15 +; CHECK-NEXT: vsrl.vv v16, v8, v16 +; CHECK-NEXT: vrsub.vi v12, v12, 0 +; CHECK-NEXT: vand.vi v12, v12, 15 +; CHECK-NEXT: vsll.vv v8, v8, v12 +; CHECK-NEXT: vor.vv v8, v16, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv16i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, m4, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v12 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv16i16( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv16i16( %a, i16 %b) { +; CHECK-LABEL: vror_vx_nxv16i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, m4, ta, ma +; CHECK-NEXT: vmv.v.x v12, a0 +; CHECK-NEXT: vand.vi v16, v12, 15 +; CHECK-NEXT: vsrl.vv v16, v8, v16 +; CHECK-NEXT: vrsub.vi v12, v12, 0 +; CHECK-NEXT: vand.vi v12, v12, 15 +; CHECK-NEXT: vsll.vv v8, v8, v12 +; CHECK-NEXT: vor.vv v8, v16, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vx_nxv16i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e16, m4, ta, ma +; CHECK-ZVBB-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i16 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv16i16( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv16i16( %a) { +; CHECK-LABEL: vror_vi_nxv16i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, ma +; CHECK-NEXT: vsll.vi v12, v8, 15 +; CHECK-NEXT: vsrl.vi v8, v8, 1 +; CHECK-NEXT: vor.vv v8, v8, v12 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv16i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, m4, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv16i16( %a, %a, shufflevector( insertelement( poison, i16 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv16i16( %a) { +; CHECK-LABEL: vror_vi_rotl_nxv16i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, ma +; CHECK-NEXT: vsrl.vi v12, v8, 15 +; CHECK-NEXT: vadd.vv v8, v8, v8 +; CHECK-NEXT: vor.vv v8, v8, v12 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv16i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, m4, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv16i16( %a, %a, shufflevector( insertelement( poison, i16 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv32i16(, , ) +declare @llvm.fshl.nxv32i16(, , ) + +define @vror_vv_nxv32i16( %a, %b) { +; CHECK-LABEL: vror_vv_nxv32i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, m8, ta, ma +; CHECK-NEXT: vand.vi v24, v16, 15 +; CHECK-NEXT: vsrl.vv v24, v8, v24 +; CHECK-NEXT: vrsub.vi v16, v16, 0 +; CHECK-NEXT: vand.vi v16, v16, 15 +; CHECK-NEXT: vsll.vv v8, v8, v16 +; CHECK-NEXT: vor.vv v8, v24, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv32i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, m8, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v16 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv32i16( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv32i16( %a, i16 %b) { +; CHECK-LABEL: vror_vx_nxv32i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, m8, ta, ma +; CHECK-NEXT: vmv.v.x v16, a0 +; CHECK-NEXT: vand.vi v24, v16, 15 +; CHECK-NEXT: vsrl.vv v24, v8, v24 +; CHECK-NEXT: vrsub.vi v16, v16, 0 +; CHECK-NEXT: vand.vi v16, v16, 15 +; CHECK-NEXT: vsll.vv v8, v8, v16 +; CHECK-NEXT: vor.vv v8, v24, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vx_nxv32i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e16, m8, ta, ma +; CHECK-ZVBB-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i16 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv32i16( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv32i16( %a) { +; CHECK-LABEL: vror_vi_nxv32i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, m8, ta, ma +; CHECK-NEXT: vsll.vi v16, v8, 15 +; CHECK-NEXT: vsrl.vi v8, v8, 1 +; CHECK-NEXT: vor.vv v8, v8, v16 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv32i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, m8, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv32i16( %a, %a, shufflevector( insertelement( poison, i16 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv32i16( %a) { +; CHECK-LABEL: vror_vi_rotl_nxv32i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16, m8, ta, ma +; CHECK-NEXT: vsrl.vi v16, v8, 15 +; CHECK-NEXT: vadd.vv v8, v8, v8 +; CHECK-NEXT: vor.vv v8, v8, v16 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv32i16: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e16, m8, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv32i16( %a, %a, shufflevector( insertelement( poison, i16 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv1i32(, , ) +declare @llvm.fshl.nxv1i32(, , ) + +define @vror_vv_nxv1i32( %a, %b) { +; CHECK-LABEL: vror_vv_nxv1i32: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 31 +; CHECK-NEXT: vsetvli a1, zero, e32, mf2, ta, ma +; CHECK-NEXT: vand.vx v10, v9, a0 +; CHECK-NEXT: vsrl.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vx v9, v9, a0 +; CHECK-NEXT: vsll.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv1i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e32, mf2, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v9 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv1i32( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv1i32( %a, i32 %b) { +; CHECK-RV32-LABEL: vror_vx_nxv1i32: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: andi a1, a0, 31 +; CHECK-RV32-NEXT: vsetvli a2, zero, e32, mf2, ta, ma +; CHECK-RV32-NEXT: vsrl.vx v9, v8, a1 +; CHECK-RV32-NEXT: neg a0, a0 +; CHECK-RV32-NEXT: andi a0, a0, 31 +; CHECK-RV32-NEXT: vsll.vx v8, v8, a0 +; CHECK-RV32-NEXT: vor.vv v8, v9, v8 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vror_vx_nxv1i32: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: vsetvli a1, zero, e32, mf2, ta, ma +; CHECK-RV64-NEXT: vmv.v.x v9, a0 +; CHECK-RV64-NEXT: li a0, 31 +; CHECK-RV64-NEXT: vand.vx v10, v9, a0 +; CHECK-RV64-NEXT: vsrl.vv v10, v8, v10 +; CHECK-RV64-NEXT: vrsub.vi v9, v9, 0 +; CHECK-RV64-NEXT: vand.vx v9, v9, a0 +; CHECK-RV64-NEXT: vsll.vv v8, v8, v9 +; CHECK-RV64-NEXT: vor.vv v8, v10, v8 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vx_nxv1i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e32, mf2, ta, ma +; CHECK-ZVBB-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i32 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv1i32( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv1i32( %a) { +; CHECK-LABEL: vror_vi_nxv1i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, ma +; CHECK-NEXT: vsll.vi v9, v8, 31 +; CHECK-NEXT: vsrl.vi v8, v8, 1 +; CHECK-NEXT: vor.vv v8, v8, v9 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv1i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e32, mf2, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv1i32( %a, %a, shufflevector( insertelement( poison, i32 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv1i32( %a) { +; CHECK-LABEL: vror_vi_rotl_nxv1i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, ma +; CHECK-NEXT: vsrl.vi v9, v8, 31 +; CHECK-NEXT: vadd.vv v8, v8, v8 +; CHECK-NEXT: vor.vv v8, v8, v9 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv1i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e32, mf2, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv1i32( %a, %a, shufflevector( insertelement( poison, i32 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv2i32(, , ) +declare @llvm.fshl.nxv2i32(, , ) + +define @vror_vv_nxv2i32( %a, %b) { +; CHECK-LABEL: vror_vv_nxv2i32: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 31 +; CHECK-NEXT: vsetvli a1, zero, e32, m1, ta, ma +; CHECK-NEXT: vand.vx v10, v9, a0 +; CHECK-NEXT: vsrl.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vx v9, v9, a0 +; CHECK-NEXT: vsll.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv2i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e32, m1, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v9 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv2i32( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv2i32( %a, i32 %b) { +; CHECK-RV32-LABEL: vror_vx_nxv2i32: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: andi a1, a0, 31 +; CHECK-RV32-NEXT: vsetvli a2, zero, e32, m1, ta, ma +; CHECK-RV32-NEXT: vsrl.vx v9, v8, a1 +; CHECK-RV32-NEXT: neg a0, a0 +; CHECK-RV32-NEXT: andi a0, a0, 31 +; CHECK-RV32-NEXT: vsll.vx v8, v8, a0 +; CHECK-RV32-NEXT: vor.vv v8, v9, v8 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vror_vx_nxv2i32: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: vsetvli a1, zero, e32, m1, ta, ma +; CHECK-RV64-NEXT: vmv.v.x v9, a0 +; CHECK-RV64-NEXT: li a0, 31 +; CHECK-RV64-NEXT: vand.vx v10, v9, a0 +; CHECK-RV64-NEXT: vsrl.vv v10, v8, v10 +; CHECK-RV64-NEXT: vrsub.vi v9, v9, 0 +; CHECK-RV64-NEXT: vand.vx v9, v9, a0 +; CHECK-RV64-NEXT: vsll.vv v8, v8, v9 +; CHECK-RV64-NEXT: vor.vv v8, v10, v8 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vx_nxv2i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e32, m1, ta, ma +; CHECK-ZVBB-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i32 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv2i32( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv2i32( %a) { +; CHECK-LABEL: vror_vi_nxv2i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, ma +; CHECK-NEXT: vsll.vi v9, v8, 31 +; CHECK-NEXT: vsrl.vi v8, v8, 1 +; CHECK-NEXT: vor.vv v8, v8, v9 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv2i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e32, m1, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv2i32( %a, %a, shufflevector( insertelement( poison, i32 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv2i32( %a) { +; CHECK-LABEL: vror_vi_rotl_nxv2i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, ma +; CHECK-NEXT: vsrl.vi v9, v8, 31 +; CHECK-NEXT: vadd.vv v8, v8, v8 +; CHECK-NEXT: vor.vv v8, v8, v9 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv2i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e32, m1, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv2i32( %a, %a, shufflevector( insertelement( poison, i32 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv4i32(, , ) +declare @llvm.fshl.nxv4i32(, , ) + +define @vror_vv_nxv4i32( %a, %b) { +; CHECK-LABEL: vror_vv_nxv4i32: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 31 +; CHECK-NEXT: vsetvli a1, zero, e32, m2, ta, ma +; CHECK-NEXT: vand.vx v12, v10, a0 +; CHECK-NEXT: vsrl.vv v12, v8, v12 +; CHECK-NEXT: vrsub.vi v10, v10, 0 +; CHECK-NEXT: vand.vx v10, v10, a0 +; CHECK-NEXT: vsll.vv v8, v8, v10 +; CHECK-NEXT: vor.vv v8, v12, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv4i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e32, m2, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v10 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv4i32( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv4i32( %a, i32 %b) { +; CHECK-RV32-LABEL: vror_vx_nxv4i32: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: andi a1, a0, 31 +; CHECK-RV32-NEXT: vsetvli a2, zero, e32, m2, ta, ma +; CHECK-RV32-NEXT: vsrl.vx v10, v8, a1 +; CHECK-RV32-NEXT: neg a0, a0 +; CHECK-RV32-NEXT: andi a0, a0, 31 +; CHECK-RV32-NEXT: vsll.vx v8, v8, a0 +; CHECK-RV32-NEXT: vor.vv v8, v10, v8 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vror_vx_nxv4i32: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: vsetvli a1, zero, e32, m2, ta, ma +; CHECK-RV64-NEXT: vmv.v.x v10, a0 +; CHECK-RV64-NEXT: li a0, 31 +; CHECK-RV64-NEXT: vand.vx v12, v10, a0 +; CHECK-RV64-NEXT: vsrl.vv v12, v8, v12 +; CHECK-RV64-NEXT: vrsub.vi v10, v10, 0 +; CHECK-RV64-NEXT: vand.vx v10, v10, a0 +; CHECK-RV64-NEXT: vsll.vv v8, v8, v10 +; CHECK-RV64-NEXT: vor.vv v8, v12, v8 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vx_nxv4i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e32, m2, ta, ma +; CHECK-ZVBB-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i32 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv4i32( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv4i32( %a) { +; CHECK-LABEL: vror_vi_nxv4i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma +; CHECK-NEXT: vsll.vi v10, v8, 31 +; CHECK-NEXT: vsrl.vi v8, v8, 1 +; CHECK-NEXT: vor.vv v8, v8, v10 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv4i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e32, m2, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv4i32( %a, %a, shufflevector( insertelement( poison, i32 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv4i32( %a) { +; CHECK-LABEL: vror_vi_rotl_nxv4i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma +; CHECK-NEXT: vsrl.vi v10, v8, 31 +; CHECK-NEXT: vadd.vv v8, v8, v8 +; CHECK-NEXT: vor.vv v8, v8, v10 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv4i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e32, m2, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv4i32( %a, %a, shufflevector( insertelement( poison, i32 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv8i32(, , ) +declare @llvm.fshl.nxv8i32(, , ) + +define @vror_vv_nxv8i32( %a, %b) { +; CHECK-LABEL: vror_vv_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 31 +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, ma +; CHECK-NEXT: vand.vx v16, v12, a0 +; CHECK-NEXT: vsrl.vv v16, v8, v16 +; CHECK-NEXT: vrsub.vi v12, v12, 0 +; CHECK-NEXT: vand.vx v12, v12, a0 +; CHECK-NEXT: vsll.vv v8, v8, v12 +; CHECK-NEXT: vor.vv v8, v16, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv8i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e32, m4, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v12 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv8i32( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv8i32( %a, i32 %b) { +; CHECK-RV32-LABEL: vror_vx_nxv8i32: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: andi a1, a0, 31 +; CHECK-RV32-NEXT: vsetvli a2, zero, e32, m4, ta, ma +; CHECK-RV32-NEXT: vsrl.vx v12, v8, a1 +; CHECK-RV32-NEXT: neg a0, a0 +; CHECK-RV32-NEXT: andi a0, a0, 31 +; CHECK-RV32-NEXT: vsll.vx v8, v8, a0 +; CHECK-RV32-NEXT: vor.vv v8, v12, v8 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vror_vx_nxv8i32: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: vsetvli a1, zero, e32, m4, ta, ma +; CHECK-RV64-NEXT: vmv.v.x v12, a0 +; CHECK-RV64-NEXT: li a0, 31 +; CHECK-RV64-NEXT: vand.vx v16, v12, a0 +; CHECK-RV64-NEXT: vsrl.vv v16, v8, v16 +; CHECK-RV64-NEXT: vrsub.vi v12, v12, 0 +; CHECK-RV64-NEXT: vand.vx v12, v12, a0 +; CHECK-RV64-NEXT: vsll.vv v8, v8, v12 +; CHECK-RV64-NEXT: vor.vv v8, v16, v8 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vx_nxv8i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e32, m4, ta, ma +; CHECK-ZVBB-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i32 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv8i32( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv8i32( %a) { +; CHECK-LABEL: vror_vi_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma +; CHECK-NEXT: vsll.vi v12, v8, 31 +; CHECK-NEXT: vsrl.vi v8, v8, 1 +; CHECK-NEXT: vor.vv v8, v8, v12 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv8i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e32, m4, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv8i32( %a, %a, shufflevector( insertelement( poison, i32 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv8i32( %a) { +; CHECK-LABEL: vror_vi_rotl_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma +; CHECK-NEXT: vsrl.vi v12, v8, 31 +; CHECK-NEXT: vadd.vv v8, v8, v8 +; CHECK-NEXT: vor.vv v8, v8, v12 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv8i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e32, m4, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv8i32( %a, %a, shufflevector( insertelement( poison, i32 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv16i32(, , ) +declare @llvm.fshl.nxv16i32(, , ) + +define @vror_vv_nxv16i32( %a, %b) { +; CHECK-LABEL: vror_vv_nxv16i32: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 31 +; CHECK-NEXT: vsetvli a1, zero, e32, m8, ta, ma +; CHECK-NEXT: vand.vx v24, v16, a0 +; CHECK-NEXT: vsrl.vv v24, v8, v24 +; CHECK-NEXT: vrsub.vi v16, v16, 0 +; CHECK-NEXT: vand.vx v16, v16, a0 +; CHECK-NEXT: vsll.vv v8, v8, v16 +; CHECK-NEXT: vor.vv v8, v24, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv16i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e32, m8, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v16 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv16i32( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv16i32( %a, i32 %b) { +; CHECK-RV32-LABEL: vror_vx_nxv16i32: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: andi a1, a0, 31 +; CHECK-RV32-NEXT: vsetvli a2, zero, e32, m8, ta, ma +; CHECK-RV32-NEXT: vsrl.vx v16, v8, a1 +; CHECK-RV32-NEXT: neg a0, a0 +; CHECK-RV32-NEXT: andi a0, a0, 31 +; CHECK-RV32-NEXT: vsll.vx v8, v8, a0 +; CHECK-RV32-NEXT: vor.vv v8, v16, v8 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vror_vx_nxv16i32: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: vsetvli a1, zero, e32, m8, ta, ma +; CHECK-RV64-NEXT: vmv.v.x v16, a0 +; CHECK-RV64-NEXT: li a0, 31 +; CHECK-RV64-NEXT: vand.vx v24, v16, a0 +; CHECK-RV64-NEXT: vsrl.vv v24, v8, v24 +; CHECK-RV64-NEXT: vrsub.vi v16, v16, 0 +; CHECK-RV64-NEXT: vand.vx v16, v16, a0 +; CHECK-RV64-NEXT: vsll.vv v8, v8, v16 +; CHECK-RV64-NEXT: vor.vv v8, v24, v8 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vx_nxv16i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a1, zero, e32, m8, ta, ma +; CHECK-ZVBB-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB-NEXT: ret + %b.head = insertelement poison, i32 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv16i32( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv16i32( %a) { +; CHECK-LABEL: vror_vi_nxv16i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, ma +; CHECK-NEXT: vsll.vi v16, v8, 31 +; CHECK-NEXT: vsrl.vi v8, v8, 1 +; CHECK-NEXT: vor.vv v8, v8, v16 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv16i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e32, m8, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv16i32( %a, %a, shufflevector( insertelement( poison, i32 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv16i32( %a) { +; CHECK-LABEL: vror_vi_rotl_nxv16i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, ma +; CHECK-NEXT: vsrl.vi v16, v8, 31 +; CHECK-NEXT: vadd.vv v8, v8, v8 +; CHECK-NEXT: vor.vv v8, v8, v16 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv16i32: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e32, m8, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv16i32( %a, %a, shufflevector( insertelement( poison, i32 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv1i64(, , ) +declare @llvm.fshl.nxv1i64(, , ) + +define @vror_vv_nxv1i64( %a, %b) { +; CHECK-LABEL: vror_vv_nxv1i64: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 63 +; CHECK-NEXT: vsetvli a1, zero, e64, m1, ta, ma +; CHECK-NEXT: vand.vx v10, v9, a0 +; CHECK-NEXT: vsrl.vv v10, v8, v10 +; CHECK-NEXT: vrsub.vi v9, v9, 0 +; CHECK-NEXT: vand.vx v9, v9, a0 +; CHECK-NEXT: vsll.vv v8, v8, v9 +; CHECK-NEXT: vor.vv v8, v10, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv1i64: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e64, m1, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v9 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv1i64( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv1i64( %a, i64 %b) { +; CHECK-RV32-LABEL: vror_vx_nxv1i64: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: addi sp, sp, -16 +; CHECK-RV32-NEXT: .cfi_def_cfa_offset 16 +; CHECK-RV32-NEXT: sw a1, 12(sp) +; CHECK-RV32-NEXT: sw a0, 8(sp) +; CHECK-RV32-NEXT: addi a0, sp, 8 +; CHECK-RV32-NEXT: vsetvli a1, zero, e64, m1, ta, ma +; CHECK-RV32-NEXT: vlse64.v v9, (a0), zero +; CHECK-RV32-NEXT: li a0, 63 +; CHECK-RV32-NEXT: vand.vx v10, v9, a0 +; CHECK-RV32-NEXT: vsrl.vv v10, v8, v10 +; CHECK-RV32-NEXT: vrsub.vi v9, v9, 0 +; CHECK-RV32-NEXT: vand.vx v9, v9, a0 +; CHECK-RV32-NEXT: vsll.vv v8, v8, v9 +; CHECK-RV32-NEXT: vor.vv v8, v10, v8 +; CHECK-RV32-NEXT: addi sp, sp, 16 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vror_vx_nxv1i64: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: andi a1, a0, 63 +; CHECK-RV64-NEXT: vsetvli a2, zero, e64, m1, ta, ma +; CHECK-RV64-NEXT: vsrl.vx v9, v8, a1 +; CHECK-RV64-NEXT: negw a0, a0 +; CHECK-RV64-NEXT: andi a0, a0, 63 +; CHECK-RV64-NEXT: vsll.vx v8, v8, a0 +; CHECK-RV64-NEXT: vor.vv v8, v9, v8 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB32-LABEL: vror_vx_nxv1i64: +; CHECK-ZVBB32: # %bb.0: +; CHECK-ZVBB32-NEXT: addi sp, sp, -16 +; CHECK-ZVBB32-NEXT: .cfi_def_cfa_offset 16 +; CHECK-ZVBB32-NEXT: sw a1, 12(sp) +; CHECK-ZVBB32-NEXT: sw a0, 8(sp) +; CHECK-ZVBB32-NEXT: addi a0, sp, 8 +; CHECK-ZVBB32-NEXT: vsetvli a1, zero, e64, m1, ta, ma +; CHECK-ZVBB32-NEXT: vlse64.v v9, (a0), zero +; CHECK-ZVBB32-NEXT: vror.vv v8, v8, v9 +; CHECK-ZVBB32-NEXT: addi sp, sp, 16 +; CHECK-ZVBB32-NEXT: ret +; +; CHECK-ZVBB64-LABEL: vror_vx_nxv1i64: +; CHECK-ZVBB64: # %bb.0: +; CHECK-ZVBB64-NEXT: vsetvli a1, zero, e64, m1, ta, ma +; CHECK-ZVBB64-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB64-NEXT: ret + %b.head = insertelement poison, i64 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv1i64( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv1i64( %a) { +; CHECK-RV32-LABEL: vror_vi_nxv1i64: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: li a0, 63 +; CHECK-RV32-NEXT: vsetvli a1, zero, e64, m1, ta, ma +; CHECK-RV32-NEXT: vmv.v.x v9, a0 +; CHECK-RV32-NEXT: vand.vi v9, v9, 1 +; CHECK-RV32-NEXT: vsrl.vv v9, v8, v9 +; CHECK-RV32-NEXT: vmv.v.i v10, 1 +; CHECK-RV32-NEXT: vrsub.vi v10, v10, 0 +; CHECK-RV32-NEXT: vand.vx v10, v10, a0 +; CHECK-RV32-NEXT: vsll.vv v8, v8, v10 +; CHECK-RV32-NEXT: vor.vv v8, v9, v8 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vror_vi_nxv1i64: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: li a0, 63 +; CHECK-RV64-NEXT: vsetvli a1, zero, e64, m1, ta, ma +; CHECK-RV64-NEXT: vsll.vx v9, v8, a0 +; CHECK-RV64-NEXT: vsrl.vi v8, v8, 1 +; CHECK-RV64-NEXT: vor.vv v8, v8, v9 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv1i64: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e64, m1, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv1i64( %a, %a, shufflevector( insertelement( poison, i64 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv1i64( %a) { +; CHECK-RV32-LABEL: vror_vi_rotl_nxv1i64: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: li a0, 63 +; CHECK-RV32-NEXT: vsetvli a1, zero, e64, m1, ta, ma +; CHECK-RV32-NEXT: vmv.v.x v9, a0 +; CHECK-RV32-NEXT: vand.vi v9, v9, 1 +; CHECK-RV32-NEXT: vsll.vv v9, v8, v9 +; CHECK-RV32-NEXT: vmv.v.i v10, 1 +; CHECK-RV32-NEXT: vrsub.vi v10, v10, 0 +; CHECK-RV32-NEXT: vand.vx v10, v10, a0 +; CHECK-RV32-NEXT: vsrl.vv v8, v8, v10 +; CHECK-RV32-NEXT: vor.vv v8, v9, v8 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vror_vi_rotl_nxv1i64: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: li a0, 63 +; CHECK-RV64-NEXT: vsetvli a1, zero, e64, m1, ta, ma +; CHECK-RV64-NEXT: vsrl.vx v9, v8, a0 +; CHECK-RV64-NEXT: vadd.vv v8, v8, v8 +; CHECK-RV64-NEXT: vor.vv v8, v8, v9 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv1i64: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e64, m1, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv1i64( %a, %a, shufflevector( insertelement( poison, i64 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv2i64(, , ) +declare @llvm.fshl.nxv2i64(, , ) + +define @vror_vv_nxv2i64( %a, %b) { +; CHECK-LABEL: vror_vv_nxv2i64: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 63 +; CHECK-NEXT: vsetvli a1, zero, e64, m2, ta, ma +; CHECK-NEXT: vand.vx v12, v10, a0 +; CHECK-NEXT: vsrl.vv v12, v8, v12 +; CHECK-NEXT: vrsub.vi v10, v10, 0 +; CHECK-NEXT: vand.vx v10, v10, a0 +; CHECK-NEXT: vsll.vv v8, v8, v10 +; CHECK-NEXT: vor.vv v8, v12, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv2i64: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e64, m2, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v10 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv2i64( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv2i64( %a, i64 %b) { +; CHECK-RV32-LABEL: vror_vx_nxv2i64: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: addi sp, sp, -16 +; CHECK-RV32-NEXT: .cfi_def_cfa_offset 16 +; CHECK-RV32-NEXT: sw a1, 12(sp) +; CHECK-RV32-NEXT: sw a0, 8(sp) +; CHECK-RV32-NEXT: addi a0, sp, 8 +; CHECK-RV32-NEXT: vsetvli a1, zero, e64, m2, ta, ma +; CHECK-RV32-NEXT: vlse64.v v10, (a0), zero +; CHECK-RV32-NEXT: li a0, 63 +; CHECK-RV32-NEXT: vand.vx v12, v10, a0 +; CHECK-RV32-NEXT: vsrl.vv v12, v8, v12 +; CHECK-RV32-NEXT: vrsub.vi v10, v10, 0 +; CHECK-RV32-NEXT: vand.vx v10, v10, a0 +; CHECK-RV32-NEXT: vsll.vv v8, v8, v10 +; CHECK-RV32-NEXT: vor.vv v8, v12, v8 +; CHECK-RV32-NEXT: addi sp, sp, 16 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vror_vx_nxv2i64: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: andi a1, a0, 63 +; CHECK-RV64-NEXT: vsetvli a2, zero, e64, m2, ta, ma +; CHECK-RV64-NEXT: vsrl.vx v10, v8, a1 +; CHECK-RV64-NEXT: negw a0, a0 +; CHECK-RV64-NEXT: andi a0, a0, 63 +; CHECK-RV64-NEXT: vsll.vx v8, v8, a0 +; CHECK-RV64-NEXT: vor.vv v8, v10, v8 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB32-LABEL: vror_vx_nxv2i64: +; CHECK-ZVBB32: # %bb.0: +; CHECK-ZVBB32-NEXT: addi sp, sp, -16 +; CHECK-ZVBB32-NEXT: .cfi_def_cfa_offset 16 +; CHECK-ZVBB32-NEXT: sw a1, 12(sp) +; CHECK-ZVBB32-NEXT: sw a0, 8(sp) +; CHECK-ZVBB32-NEXT: addi a0, sp, 8 +; CHECK-ZVBB32-NEXT: vsetvli a1, zero, e64, m2, ta, ma +; CHECK-ZVBB32-NEXT: vlse64.v v10, (a0), zero +; CHECK-ZVBB32-NEXT: vror.vv v8, v8, v10 +; CHECK-ZVBB32-NEXT: addi sp, sp, 16 +; CHECK-ZVBB32-NEXT: ret +; +; CHECK-ZVBB64-LABEL: vror_vx_nxv2i64: +; CHECK-ZVBB64: # %bb.0: +; CHECK-ZVBB64-NEXT: vsetvli a1, zero, e64, m2, ta, ma +; CHECK-ZVBB64-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB64-NEXT: ret + %b.head = insertelement poison, i64 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv2i64( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv2i64( %a) { +; CHECK-RV32-LABEL: vror_vi_nxv2i64: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: li a0, 63 +; CHECK-RV32-NEXT: vsetvli a1, zero, e64, m2, ta, ma +; CHECK-RV32-NEXT: vmv.v.x v10, a0 +; CHECK-RV32-NEXT: vand.vi v10, v10, 1 +; CHECK-RV32-NEXT: vsrl.vv v10, v8, v10 +; CHECK-RV32-NEXT: vmv.v.i v12, 1 +; CHECK-RV32-NEXT: vrsub.vi v12, v12, 0 +; CHECK-RV32-NEXT: vand.vx v12, v12, a0 +; CHECK-RV32-NEXT: vsll.vv v8, v8, v12 +; CHECK-RV32-NEXT: vor.vv v8, v10, v8 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vror_vi_nxv2i64: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: li a0, 63 +; CHECK-RV64-NEXT: vsetvli a1, zero, e64, m2, ta, ma +; CHECK-RV64-NEXT: vsll.vx v10, v8, a0 +; CHECK-RV64-NEXT: vsrl.vi v8, v8, 1 +; CHECK-RV64-NEXT: vor.vv v8, v8, v10 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv2i64: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e64, m2, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv2i64( %a, %a, shufflevector( insertelement( poison, i64 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv2i64( %a) { +; CHECK-RV32-LABEL: vror_vi_rotl_nxv2i64: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: li a0, 63 +; CHECK-RV32-NEXT: vsetvli a1, zero, e64, m2, ta, ma +; CHECK-RV32-NEXT: vmv.v.x v10, a0 +; CHECK-RV32-NEXT: vand.vi v10, v10, 1 +; CHECK-RV32-NEXT: vsll.vv v10, v8, v10 +; CHECK-RV32-NEXT: vmv.v.i v12, 1 +; CHECK-RV32-NEXT: vrsub.vi v12, v12, 0 +; CHECK-RV32-NEXT: vand.vx v12, v12, a0 +; CHECK-RV32-NEXT: vsrl.vv v8, v8, v12 +; CHECK-RV32-NEXT: vor.vv v8, v10, v8 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vror_vi_rotl_nxv2i64: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: li a0, 63 +; CHECK-RV64-NEXT: vsetvli a1, zero, e64, m2, ta, ma +; CHECK-RV64-NEXT: vsrl.vx v10, v8, a0 +; CHECK-RV64-NEXT: vadd.vv v8, v8, v8 +; CHECK-RV64-NEXT: vor.vv v8, v8, v10 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv2i64: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e64, m2, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv2i64( %a, %a, shufflevector( insertelement( poison, i64 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv4i64(, , ) +declare @llvm.fshl.nxv4i64(, , ) + +define @vror_vv_nxv4i64( %a, %b) { +; CHECK-LABEL: vror_vv_nxv4i64: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 63 +; CHECK-NEXT: vsetvli a1, zero, e64, m4, ta, ma +; CHECK-NEXT: vand.vx v16, v12, a0 +; CHECK-NEXT: vsrl.vv v16, v8, v16 +; CHECK-NEXT: vrsub.vi v12, v12, 0 +; CHECK-NEXT: vand.vx v12, v12, a0 +; CHECK-NEXT: vsll.vv v8, v8, v12 +; CHECK-NEXT: vor.vv v8, v16, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv4i64: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e64, m4, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v12 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv4i64( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv4i64( %a, i64 %b) { +; CHECK-RV32-LABEL: vror_vx_nxv4i64: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: addi sp, sp, -16 +; CHECK-RV32-NEXT: .cfi_def_cfa_offset 16 +; CHECK-RV32-NEXT: sw a1, 12(sp) +; CHECK-RV32-NEXT: sw a0, 8(sp) +; CHECK-RV32-NEXT: addi a0, sp, 8 +; CHECK-RV32-NEXT: vsetvli a1, zero, e64, m4, ta, ma +; CHECK-RV32-NEXT: vlse64.v v12, (a0), zero +; CHECK-RV32-NEXT: li a0, 63 +; CHECK-RV32-NEXT: vand.vx v16, v12, a0 +; CHECK-RV32-NEXT: vsrl.vv v16, v8, v16 +; CHECK-RV32-NEXT: vrsub.vi v12, v12, 0 +; CHECK-RV32-NEXT: vand.vx v12, v12, a0 +; CHECK-RV32-NEXT: vsll.vv v8, v8, v12 +; CHECK-RV32-NEXT: vor.vv v8, v16, v8 +; CHECK-RV32-NEXT: addi sp, sp, 16 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vror_vx_nxv4i64: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: andi a1, a0, 63 +; CHECK-RV64-NEXT: vsetvli a2, zero, e64, m4, ta, ma +; CHECK-RV64-NEXT: vsrl.vx v12, v8, a1 +; CHECK-RV64-NEXT: negw a0, a0 +; CHECK-RV64-NEXT: andi a0, a0, 63 +; CHECK-RV64-NEXT: vsll.vx v8, v8, a0 +; CHECK-RV64-NEXT: vor.vv v8, v12, v8 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB32-LABEL: vror_vx_nxv4i64: +; CHECK-ZVBB32: # %bb.0: +; CHECK-ZVBB32-NEXT: addi sp, sp, -16 +; CHECK-ZVBB32-NEXT: .cfi_def_cfa_offset 16 +; CHECK-ZVBB32-NEXT: sw a1, 12(sp) +; CHECK-ZVBB32-NEXT: sw a0, 8(sp) +; CHECK-ZVBB32-NEXT: addi a0, sp, 8 +; CHECK-ZVBB32-NEXT: vsetvli a1, zero, e64, m4, ta, ma +; CHECK-ZVBB32-NEXT: vlse64.v v12, (a0), zero +; CHECK-ZVBB32-NEXT: vror.vv v8, v8, v12 +; CHECK-ZVBB32-NEXT: addi sp, sp, 16 +; CHECK-ZVBB32-NEXT: ret +; +; CHECK-ZVBB64-LABEL: vror_vx_nxv4i64: +; CHECK-ZVBB64: # %bb.0: +; CHECK-ZVBB64-NEXT: vsetvli a1, zero, e64, m4, ta, ma +; CHECK-ZVBB64-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB64-NEXT: ret + %b.head = insertelement poison, i64 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv4i64( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv4i64( %a) { +; CHECK-RV32-LABEL: vror_vi_nxv4i64: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: li a0, 63 +; CHECK-RV32-NEXT: vsetvli a1, zero, e64, m4, ta, ma +; CHECK-RV32-NEXT: vmv.v.x v12, a0 +; CHECK-RV32-NEXT: vand.vi v12, v12, 1 +; CHECK-RV32-NEXT: vsrl.vv v12, v8, v12 +; CHECK-RV32-NEXT: vmv.v.i v16, 1 +; CHECK-RV32-NEXT: vrsub.vi v16, v16, 0 +; CHECK-RV32-NEXT: vand.vx v16, v16, a0 +; CHECK-RV32-NEXT: vsll.vv v8, v8, v16 +; CHECK-RV32-NEXT: vor.vv v8, v12, v8 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vror_vi_nxv4i64: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: li a0, 63 +; CHECK-RV64-NEXT: vsetvli a1, zero, e64, m4, ta, ma +; CHECK-RV64-NEXT: vsll.vx v12, v8, a0 +; CHECK-RV64-NEXT: vsrl.vi v8, v8, 1 +; CHECK-RV64-NEXT: vor.vv v8, v8, v12 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv4i64: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e64, m4, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv4i64( %a, %a, shufflevector( insertelement( poison, i64 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv4i64( %a) { +; CHECK-RV32-LABEL: vror_vi_rotl_nxv4i64: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: li a0, 63 +; CHECK-RV32-NEXT: vsetvli a1, zero, e64, m4, ta, ma +; CHECK-RV32-NEXT: vmv.v.x v12, a0 +; CHECK-RV32-NEXT: vand.vi v12, v12, 1 +; CHECK-RV32-NEXT: vsll.vv v12, v8, v12 +; CHECK-RV32-NEXT: vmv.v.i v16, 1 +; CHECK-RV32-NEXT: vrsub.vi v16, v16, 0 +; CHECK-RV32-NEXT: vand.vx v16, v16, a0 +; CHECK-RV32-NEXT: vsrl.vv v8, v8, v16 +; CHECK-RV32-NEXT: vor.vv v8, v12, v8 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vror_vi_rotl_nxv4i64: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: li a0, 63 +; CHECK-RV64-NEXT: vsetvli a1, zero, e64, m4, ta, ma +; CHECK-RV64-NEXT: vsrl.vx v12, v8, a0 +; CHECK-RV64-NEXT: vadd.vv v8, v8, v8 +; CHECK-RV64-NEXT: vor.vv v8, v8, v12 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv4i64: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e64, m4, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv4i64( %a, %a, shufflevector( insertelement( poison, i64 1, i32 0), poison, zeroinitializer)) + ret %x +} + +declare @llvm.fshr.nxv8i64(, , ) +declare @llvm.fshl.nxv8i64(, , ) + +define @vror_vv_nxv8i64( %a, %b) { +; CHECK-LABEL: vror_vv_nxv8i64: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 63 +; CHECK-NEXT: vsetvli a1, zero, e64, m8, ta, ma +; CHECK-NEXT: vand.vx v24, v16, a0 +; CHECK-NEXT: vsrl.vv v24, v8, v24 +; CHECK-NEXT: vrsub.vi v16, v16, 0 +; CHECK-NEXT: vand.vx v16, v16, a0 +; CHECK-NEXT: vsll.vv v8, v8, v16 +; CHECK-NEXT: vor.vv v8, v24, v8 +; CHECK-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vv_nxv8i64: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e64, m8, ta, ma +; CHECK-ZVBB-NEXT: vror.vv v8, v8, v16 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv8i64( %a, %a, %b) + ret %x +} + +define @vror_vx_nxv8i64( %a, i64 %b) { +; CHECK-RV32-LABEL: vror_vx_nxv8i64: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: addi sp, sp, -16 +; CHECK-RV32-NEXT: .cfi_def_cfa_offset 16 +; CHECK-RV32-NEXT: sw a1, 12(sp) +; CHECK-RV32-NEXT: sw a0, 8(sp) +; CHECK-RV32-NEXT: addi a0, sp, 8 +; CHECK-RV32-NEXT: vsetvli a1, zero, e64, m8, ta, ma +; CHECK-RV32-NEXT: vlse64.v v16, (a0), zero +; CHECK-RV32-NEXT: li a0, 63 +; CHECK-RV32-NEXT: vand.vx v24, v16, a0 +; CHECK-RV32-NEXT: vsrl.vv v24, v8, v24 +; CHECK-RV32-NEXT: vrsub.vi v16, v16, 0 +; CHECK-RV32-NEXT: vand.vx v16, v16, a0 +; CHECK-RV32-NEXT: vsll.vv v8, v8, v16 +; CHECK-RV32-NEXT: vor.vv v8, v24, v8 +; CHECK-RV32-NEXT: addi sp, sp, 16 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vror_vx_nxv8i64: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: andi a1, a0, 63 +; CHECK-RV64-NEXT: vsetvli a2, zero, e64, m8, ta, ma +; CHECK-RV64-NEXT: vsrl.vx v16, v8, a1 +; CHECK-RV64-NEXT: negw a0, a0 +; CHECK-RV64-NEXT: andi a0, a0, 63 +; CHECK-RV64-NEXT: vsll.vx v8, v8, a0 +; CHECK-RV64-NEXT: vor.vv v8, v16, v8 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB32-LABEL: vror_vx_nxv8i64: +; CHECK-ZVBB32: # %bb.0: +; CHECK-ZVBB32-NEXT: addi sp, sp, -16 +; CHECK-ZVBB32-NEXT: .cfi_def_cfa_offset 16 +; CHECK-ZVBB32-NEXT: sw a1, 12(sp) +; CHECK-ZVBB32-NEXT: sw a0, 8(sp) +; CHECK-ZVBB32-NEXT: addi a0, sp, 8 +; CHECK-ZVBB32-NEXT: vsetvli a1, zero, e64, m8, ta, ma +; CHECK-ZVBB32-NEXT: vlse64.v v16, (a0), zero +; CHECK-ZVBB32-NEXT: vror.vv v8, v8, v16 +; CHECK-ZVBB32-NEXT: addi sp, sp, 16 +; CHECK-ZVBB32-NEXT: ret +; +; CHECK-ZVBB64-LABEL: vror_vx_nxv8i64: +; CHECK-ZVBB64: # %bb.0: +; CHECK-ZVBB64-NEXT: vsetvli a1, zero, e64, m8, ta, ma +; CHECK-ZVBB64-NEXT: vror.vx v8, v8, a0 +; CHECK-ZVBB64-NEXT: ret + %b.head = insertelement poison, i64 %b, i32 0 + %b.splat = shufflevector %b.head, poison, zeroinitializer + %x = call @llvm.fshr.nxv8i64( %a, %a, %b.splat) + ret %x +} + +define @vror_vi_nxv8i64( %a) { +; CHECK-RV32-LABEL: vror_vi_nxv8i64: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: li a0, 63 +; CHECK-RV32-NEXT: vsetvli a1, zero, e64, m8, ta, ma +; CHECK-RV32-NEXT: vmv.v.x v16, a0 +; CHECK-RV32-NEXT: vand.vi v16, v16, 1 +; CHECK-RV32-NEXT: vsrl.vv v16, v8, v16 +; CHECK-RV32-NEXT: vmv.v.i v24, 1 +; CHECK-RV32-NEXT: vrsub.vi v24, v24, 0 +; CHECK-RV32-NEXT: vand.vx v24, v24, a0 +; CHECK-RV32-NEXT: vsll.vv v8, v8, v24 +; CHECK-RV32-NEXT: vor.vv v8, v16, v8 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vror_vi_nxv8i64: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: li a0, 63 +; CHECK-RV64-NEXT: vsetvli a1, zero, e64, m8, ta, ma +; CHECK-RV64-NEXT: vsll.vx v16, v8, a0 +; CHECK-RV64-NEXT: vsrl.vi v8, v8, 1 +; CHECK-RV64-NEXT: vor.vv v8, v8, v16 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_nxv8i64: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e64, m8, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 1 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshr.nxv8i64( %a, %a, shufflevector( insertelement( poison, i64 1, i32 0), poison, zeroinitializer)) + ret %x +} + +define @vror_vi_rotl_nxv8i64( %a) { +; CHECK-RV32-LABEL: vror_vi_rotl_nxv8i64: +; CHECK-RV32: # %bb.0: +; CHECK-RV32-NEXT: li a0, 63 +; CHECK-RV32-NEXT: vsetvli a1, zero, e64, m8, ta, ma +; CHECK-RV32-NEXT: vmv.v.x v16, a0 +; CHECK-RV32-NEXT: vand.vi v16, v16, 1 +; CHECK-RV32-NEXT: vsll.vv v16, v8, v16 +; CHECK-RV32-NEXT: vmv.v.i v24, 1 +; CHECK-RV32-NEXT: vrsub.vi v24, v24, 0 +; CHECK-RV32-NEXT: vand.vx v24, v24, a0 +; CHECK-RV32-NEXT: vsrl.vv v8, v8, v24 +; CHECK-RV32-NEXT: vor.vv v8, v16, v8 +; CHECK-RV32-NEXT: ret +; +; CHECK-RV64-LABEL: vror_vi_rotl_nxv8i64: +; CHECK-RV64: # %bb.0: +; CHECK-RV64-NEXT: li a0, 63 +; CHECK-RV64-NEXT: vsetvli a1, zero, e64, m8, ta, ma +; CHECK-RV64-NEXT: vsrl.vx v16, v8, a0 +; CHECK-RV64-NEXT: vadd.vv v8, v8, v8 +; CHECK-RV64-NEXT: vor.vv v8, v8, v16 +; CHECK-RV64-NEXT: ret +; +; CHECK-ZVBB-LABEL: vror_vi_rotl_nxv8i64: +; CHECK-ZVBB: # %bb.0: +; CHECK-ZVBB-NEXT: vsetvli a0, zero, e64, m8, ta, ma +; CHECK-ZVBB-NEXT: vror.vi v8, v8, 63 +; CHECK-ZVBB-NEXT: ret + %x = call @llvm.fshl.nxv8i64( %a, %a, shufflevector( insertelement( poison, i64 1, i32 0), poison, zeroinitializer)) + ret %x +} +