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. @@ -769,6 +767,8 @@ {ISD::CTLZ, ISD::CTLZ_ZERO_UNDEF, ISD::CTTZ_ZERO_UNDEF}, VT, Custom); } + + setOperationAction({ISD::ROTL, ISD::ROTR}, VT, Expand); } } 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,9 @@ defm : VPatUnarySDNode_V; defm : VPatUnarySDNode_V; +defm : VPatBinarySDNode_VV_VX; +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,1711 @@ +; 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(, , ) + +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 +} + + +declare @llvm.fshr.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 +} + + +declare @llvm.fshr.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 +} + + +declare @llvm.fshr.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 +} + + +declare @llvm.fshr.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 +} + + +declare @llvm.fshr.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 +} + + +declare @llvm.fshr.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 +} + + +declare @llvm.fshr.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 +} + + +declare @llvm.fshr.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 +} + + +declare @llvm.fshr.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 +} + + +declare @llvm.fshr.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 +} + + +declare @llvm.fshr.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 +} + + +declare @llvm.fshr.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 +} + + +declare @llvm.fshr.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 +} + + +declare @llvm.fshr.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 +} + + +declare @llvm.fshr.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 +} + + +declare @llvm.fshr.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 +} + + +declare @llvm.fshr.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 +} + + +declare @llvm.fshr.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 +} + + +declare @llvm.fshr.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 +} + + +declare @llvm.fshr.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 +} + + +declare @llvm.fshr.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 +} + +