diff --git a/llvm/test/CodeGen/RISCV/rvv/vnsra-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vnsra-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vnsra-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vnsra-sdnode.ll @@ -4,6 +4,66 @@ ; RUN: llc -mtriple=riscv64 -mattr=+v -target-abi=lp64 \ ; RUN: -verify-machineinstrs < %s | FileCheck %s +define @vnsra_wx_i64_nxv1i32( %va, i64 %b) { +; CHECK-LABEL: vnsra_wx_i64_nxv1i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64, m1, ta, ma +; CHECK-NEXT: vsra.vx v8, v8, a0 +; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v8, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i64 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %x = ashr %va, %splat + %y = trunc %x to + ret %y +} + +define @vnsra_wx_i64_nxv2i32( %va, i64 %b) { +; CHECK-LABEL: vnsra_wx_i64_nxv2i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64, m2, ta, ma +; CHECK-NEXT: vsra.vx v10, v8, a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v10, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i64 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %x = ashr %va, %splat + %y = trunc %x to + ret %y +} + +define @vnsra_wx_i64_nxv4i32( %va, i64 %b) { +; CHECK-LABEL: vnsra_wx_i64_nxv4i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64, m4, ta, ma +; CHECK-NEXT: vsra.vx v12, v8, a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v12, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i64 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %x = ashr %va, %splat + %y = trunc %x to + ret %y +} + +define @vnsra_wx_i64_nxv8i32( %va, i64 %b) { +; CHECK-LABEL: vnsra_wx_i64_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64, m8, ta, ma +; CHECK-NEXT: vsra.vx v16, v8, a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v16, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i64 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %x = ashr %va, %splat + %y = trunc %x to + ret %y +} + define @vnsra_wv_nxv1i32_sext( %va, %vb) { ; CHECK-LABEL: vnsra_wv_nxv1i32_sext: ; CHECK: # %bb.0: @@ -30,6 +90,44 @@ ret %y } +define @vnsra_wx_i16_nxv1i32_sext( %va, i16 %b) { +; CHECK-LABEL: vnsra_wx_i16_nxv1i32_sext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, mf4, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, ma +; CHECK-NEXT: vsext.vf4 v10, v9 +; CHECK-NEXT: vsra.vv v8, v8, v10 +; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v8, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i16 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = sext %splat to + %x = ashr %va, %vb + %y = trunc %x to + ret %y +} + +define @vnsra_wx_i8_nxv1i32_sext( %va, i8 %b) { +; CHECK-LABEL: vnsra_wx_i8_nxv1i32_sext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, mf8, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, ma +; CHECK-NEXT: vsext.vf8 v10, v9 +; CHECK-NEXT: vsra.vv v8, v8, v10 +; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v8, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i8 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = sext %splat to + %x = ashr %va, %vb + %y = trunc %x to + ret %y +} + define @vnsra_wi_i32_nxv1i32_sext( %va) { ; CHECK-LABEL: vnsra_wi_i32_nxv1i32_sext: ; CHECK: # %bb.0: @@ -72,6 +170,44 @@ ret %y } +define @vnsra_wx_i16_nxv2i32_sext( %va, i16 %b) { +; CHECK-LABEL: vnsra_wx_i16_nxv2i32_sext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma +; CHECK-NEXT: vmv.v.x v10, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma +; CHECK-NEXT: vsext.vf4 v12, v10 +; CHECK-NEXT: vsra.vv v10, v8, v12 +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v10, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i16 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = sext %splat to + %x = ashr %va, %vb + %y = trunc %x to + ret %y +} + +define @vnsra_wx_i8_nxv2i32_sext( %va, i8 %b) { +; CHECK-LABEL: vnsra_wx_i8_nxv2i32_sext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma +; CHECK-NEXT: vmv.v.x v10, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma +; CHECK-NEXT: vsext.vf8 v12, v10 +; CHECK-NEXT: vsra.vv v10, v8, v12 +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v10, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i8 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = sext %splat to + %x = ashr %va, %vb + %y = trunc %x to + ret %y +} + define @vnsra_wi_i32_nxv2i32_sext( %va) { ; CHECK-LABEL: vnsra_wi_i32_nxv2i32_sext: ; CHECK: # %bb.0: @@ -115,6 +251,44 @@ ret %y } +define @vnsra_wx_i16_nxv4i32_sext( %va, i16 %b) { +; CHECK-LABEL: vnsra_wx_i16_nxv4i32_sext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, ma +; CHECK-NEXT: vmv.v.x v12, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, ma +; CHECK-NEXT: vsext.vf4 v16, v12 +; CHECK-NEXT: vsra.vv v12, v8, v16 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v12, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i16 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = sext %splat to + %x = ashr %va, %vb + %y = trunc %x to + ret %y +} + +define @vnsra_wx_i8_nxv4i32_sext( %va, i8 %b) { +; CHECK-LABEL: vnsra_wx_i8_nxv4i32_sext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma +; CHECK-NEXT: vmv.v.x v12, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, ma +; CHECK-NEXT: vsext.vf8 v16, v12 +; CHECK-NEXT: vsra.vv v12, v8, v16 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v12, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i8 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = sext %splat to + %x = ashr %va, %vb + %y = trunc %x to + ret %y +} + define @vnsra_wi_i32_nxv4i32_sext( %va) { ; CHECK-LABEL: vnsra_wi_i32_nxv4i32_sext: ; CHECK: # %bb.0: @@ -158,6 +332,44 @@ ret %y } +define @vnsra_wx_i16_nxv8i32_sext( %va, i16 %b) { +; CHECK-LABEL: vnsra_wx_i16_nxv8i32_sext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma +; CHECK-NEXT: vmv.v.x v16, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma +; CHECK-NEXT: vsext.vf4 v24, v16 +; CHECK-NEXT: vsra.vv v16, v8, v24 +; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v16, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i16 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = sext %splat to + %x = ashr %va, %vb + %y = trunc %x to + ret %y +} + +define @vnsra_wx_i8_nxv8i32_sext( %va, i8 %b) { +; CHECK-LABEL: vnsra_wx_i8_nxv8i32_sext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, ma +; CHECK-NEXT: vmv.v.x v16, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma +; CHECK-NEXT: vsext.vf8 v24, v16 +; CHECK-NEXT: vsra.vv v16, v8, v24 +; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v16, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i8 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = sext %splat to + %x = ashr %va, %vb + %y = trunc %x to + ret %y +} + define @vnsra_wi_i32_nxv8i32_sext( %va) { ; CHECK-LABEL: vnsra_wi_i32_nxv8i32_sext: ; CHECK: # %bb.0: @@ -199,6 +411,44 @@ ret %y } +define @vnsra_wx_i16_nxv1i32_zext( %va, i16 %b) { +; CHECK-LABEL: vnsra_wx_i16_nxv1i32_zext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, mf4, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, ma +; CHECK-NEXT: vzext.vf4 v10, v9 +; CHECK-NEXT: vsra.vv v8, v8, v10 +; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v8, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i16 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = zext %splat to + %x = ashr %va, %vb + %y = trunc %x to + ret %y +} + +define @vnsra_wx_i8_nxv1i32_zext( %va, i8 %b) { +; CHECK-LABEL: vnsra_wx_i8_nxv1i32_zext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, mf8, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, ma +; CHECK-NEXT: vzext.vf8 v10, v9 +; CHECK-NEXT: vsra.vv v8, v8, v10 +; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v8, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i8 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = zext %splat to + %x = ashr %va, %vb + %y = trunc %x to + ret %y +} + define @vnsra_wi_i32_nxv1i32_zext( %va) { ; CHECK-LABEL: vnsra_wi_i32_nxv1i32_zext: ; CHECK: # %bb.0: @@ -241,6 +491,44 @@ ret %y } +define @vnsra_wx_i16_nxv2i32_zext( %va, i16 %b) { +; CHECK-LABEL: vnsra_wx_i16_nxv2i32_zext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma +; CHECK-NEXT: vmv.v.x v10, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma +; CHECK-NEXT: vzext.vf4 v12, v10 +; CHECK-NEXT: vsra.vv v10, v8, v12 +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v10, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i16 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = zext %splat to + %x = ashr %va, %vb + %y = trunc %x to + ret %y +} + +define @vnsra_wx_i8_nxv2i32_zext( %va, i8 %b) { +; CHECK-LABEL: vnsra_wx_i8_nxv2i32_zext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma +; CHECK-NEXT: vmv.v.x v10, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma +; CHECK-NEXT: vzext.vf8 v12, v10 +; CHECK-NEXT: vsra.vv v10, v8, v12 +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v10, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i8 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = zext %splat to + %x = ashr %va, %vb + %y = trunc %x to + ret %y +} + define @vnsra_wi_i32_nxv2i32_zext( %va) { ; CHECK-LABEL: vnsra_wi_i32_nxv2i32_zext: ; CHECK: # %bb.0: @@ -284,6 +572,44 @@ ret %y } +define @vnsra_wx_i16_nxv4i32_zext( %va, i16 %b) { +; CHECK-LABEL: vnsra_wx_i16_nxv4i32_zext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, ma +; CHECK-NEXT: vmv.v.x v12, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, ma +; CHECK-NEXT: vzext.vf4 v16, v12 +; CHECK-NEXT: vsra.vv v12, v8, v16 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v12, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i16 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = zext %splat to + %x = ashr %va, %vb + %y = trunc %x to + ret %y +} + +define @vnsra_wx_i8_nxv4i32_zext( %va, i8 %b) { +; CHECK-LABEL: vnsra_wx_i8_nxv4i32_zext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma +; CHECK-NEXT: vmv.v.x v12, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, ma +; CHECK-NEXT: vzext.vf8 v16, v12 +; CHECK-NEXT: vsra.vv v12, v8, v16 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v12, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i8 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = zext %splat to + %x = ashr %va, %vb + %y = trunc %x to + ret %y +} + define @vnsra_wi_i32_nxv4i32_zext( %va) { ; CHECK-LABEL: vnsra_wi_i32_nxv4i32_zext: ; CHECK: # %bb.0: @@ -327,6 +653,44 @@ ret %y } +define @vnsra_wx_i16_nxv8i32_zext( %va, i16 %b) { +; CHECK-LABEL: vnsra_wx_i16_nxv8i32_zext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma +; CHECK-NEXT: vmv.v.x v16, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma +; CHECK-NEXT: vzext.vf4 v24, v16 +; CHECK-NEXT: vsra.vv v16, v8, v24 +; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v16, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i16 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = zext %splat to + %x = ashr %va, %vb + %y = trunc %x to + ret %y +} + +define @vnsra_wx_i8_nxv8i32_zext( %va, i8 %b) { +; CHECK-LABEL: vnsra_wx_i8_nxv8i32_zext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, ma +; CHECK-NEXT: vmv.v.x v16, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma +; CHECK-NEXT: vzext.vf8 v24, v16 +; CHECK-NEXT: vsra.vv v16, v8, v24 +; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v16, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i8 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = zext %splat to + %x = ashr %va, %vb + %y = trunc %x to + ret %y +} + define @vnsra_wi_i32_nxv8i32_zext( %va) { ; CHECK-LABEL: vnsra_wi_i32_nxv8i32_zext: ; CHECK: # %bb.0: diff --git a/llvm/test/CodeGen/RISCV/rvv/vnsrl-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vnsrl-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vnsrl-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vnsrl-sdnode.ll @@ -4,6 +4,66 @@ ; RUN: llc -mtriple=riscv64 -mattr=+v -target-abi=lp64 \ ; RUN: -verify-machineinstrs < %s | FileCheck %s +define @vnsrl_wx_i64_nxv1i32( %va, i64 %b) { +; CHECK-LABEL: vnsrl_wx_i64_nxv1i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64, m1, ta, ma +; CHECK-NEXT: vsrl.vx v8, v8, a0 +; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v8, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i64 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %x = lshr %va, %splat + %y = trunc %x to + ret %y +} + +define @vnsrl_wx_i64_nxv2i32( %va, i64 %b) { +; CHECK-LABEL: vnsrl_wx_i64_nxv2i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64, m2, ta, ma +; CHECK-NEXT: vsrl.vx v10, v8, a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v10, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i64 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %x = lshr %va, %splat + %y = trunc %x to + ret %y +} + +define @vnsrl_wx_i64_nxv4i32( %va, i64 %b) { +; CHECK-LABEL: vnsrl_wx_i64_nxv4i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64, m4, ta, ma +; CHECK-NEXT: vsrl.vx v12, v8, a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v12, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i64 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %x = lshr %va, %splat + %y = trunc %x to + ret %y +} + +define @vnsrl_wx_i64_nxv8i32( %va, i64 %b) { +; CHECK-LABEL: vnsrl_wx_i64_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64, m8, ta, ma +; CHECK-NEXT: vsrl.vx v16, v8, a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v16, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i64 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %x = lshr %va, %splat + %y = trunc %x to + ret %y +} + define @vnsrl_wv_nxv1i32_sext( %va, %vb) { ; CHECK-LABEL: vnsrl_wv_nxv1i32_sext: ; CHECK: # %bb.0: @@ -30,6 +90,44 @@ ret %y } +define @vnsrl_wx_i16_nxv1i32_sext( %va, i16 %b) { +; CHECK-LABEL: vnsrl_wx_i16_nxv1i32_sext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, mf4, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, ma +; CHECK-NEXT: vsext.vf4 v10, v9 +; CHECK-NEXT: vsrl.vv v8, v8, v10 +; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v8, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i16 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = sext %splat to + %x = lshr %va, %vb + %y = trunc %x to + ret %y +} + +define @vnsrl_wx_i8_nxv1i32_sext( %va, i8 %b) { +; CHECK-LABEL: vnsrl_wx_i8_nxv1i32_sext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, mf8, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, ma +; CHECK-NEXT: vsext.vf8 v10, v9 +; CHECK-NEXT: vsrl.vv v8, v8, v10 +; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v8, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i8 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = sext %splat to + %x = lshr %va, %vb + %y = trunc %x to + ret %y +} + define @vnsrl_wi_i32_nxv1i32_sext( %va) { ; CHECK-LABEL: vnsrl_wi_i32_nxv1i32_sext: ; CHECK: # %bb.0: @@ -72,6 +170,44 @@ ret %y } +define @vnsrl_wx_i16_nxv2i32_sext( %va, i16 %b) { +; CHECK-LABEL: vnsrl_wx_i16_nxv2i32_sext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma +; CHECK-NEXT: vmv.v.x v10, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma +; CHECK-NEXT: vsext.vf4 v12, v10 +; CHECK-NEXT: vsrl.vv v10, v8, v12 +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v10, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i16 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = sext %splat to + %x = lshr %va, %vb + %y = trunc %x to + ret %y +} + +define @vnsrl_wx_i8_nxv2i32_sext( %va, i8 %b) { +; CHECK-LABEL: vnsrl_wx_i8_nxv2i32_sext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma +; CHECK-NEXT: vmv.v.x v10, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma +; CHECK-NEXT: vsext.vf8 v12, v10 +; CHECK-NEXT: vsrl.vv v10, v8, v12 +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v10, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i8 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = sext %splat to + %x = lshr %va, %vb + %y = trunc %x to + ret %y +} + define @vnsrl_wi_i32_nxv2i32_sext( %va) { ; CHECK-LABEL: vnsrl_wi_i32_nxv2i32_sext: ; CHECK: # %bb.0: @@ -115,6 +251,44 @@ ret %y } +define @vnsrl_wx_i16_nxv4i32_sext( %va, i16 %b) { +; CHECK-LABEL: vnsrl_wx_i16_nxv4i32_sext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, ma +; CHECK-NEXT: vmv.v.x v12, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, ma +; CHECK-NEXT: vsext.vf4 v16, v12 +; CHECK-NEXT: vsrl.vv v12, v8, v16 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v12, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i16 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = sext %splat to + %x = lshr %va, %vb + %y = trunc %x to + ret %y +} + +define @vnsrl_wx_i8_nxv4i32_sext( %va, i8 %b) { +; CHECK-LABEL: vnsrl_wx_i8_nxv4i32_sext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma +; CHECK-NEXT: vmv.v.x v12, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, ma +; CHECK-NEXT: vsext.vf8 v16, v12 +; CHECK-NEXT: vsrl.vv v12, v8, v16 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v12, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i8 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = sext %splat to + %x = lshr %va, %vb + %y = trunc %x to + ret %y +} + define @vnsrl_wi_i32_nxv4i32_sext( %va) { ; CHECK-LABEL: vnsrl_wi_i32_nxv4i32_sext: ; CHECK: # %bb.0: @@ -158,6 +332,44 @@ ret %y } +define @vnsrl_wx_i16_nxv8i32_sext( %va, i16 %b) { +; CHECK-LABEL: vnsrl_wx_i16_nxv8i32_sext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma +; CHECK-NEXT: vmv.v.x v16, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma +; CHECK-NEXT: vsext.vf4 v24, v16 +; CHECK-NEXT: vsrl.vv v16, v8, v24 +; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v16, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i16 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = sext %splat to + %x = lshr %va, %vb + %y = trunc %x to + ret %y +} + +define @vnsrl_wx_i8_nxv8i32_sext( %va, i8 %b) { +; CHECK-LABEL: vnsrl_wx_i8_nxv8i32_sext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, ma +; CHECK-NEXT: vmv.v.x v16, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma +; CHECK-NEXT: vsext.vf8 v24, v16 +; CHECK-NEXT: vsrl.vv v16, v8, v24 +; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v16, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i8 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = sext %splat to + %x = lshr %va, %vb + %y = trunc %x to + ret %y +} + define @vnsrl_wi_i32_nxv8i32_sext( %va) { ; CHECK-LABEL: vnsrl_wi_i32_nxv8i32_sext: ; CHECK: # %bb.0: @@ -199,6 +411,44 @@ ret %y } +define @vnsrl_wx_i16_nxv1i32_zext( %va, i16 %b) { +; CHECK-LABEL: vnsrl_wx_i16_nxv1i32_zext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, mf4, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, ma +; CHECK-NEXT: vzext.vf4 v10, v9 +; CHECK-NEXT: vsrl.vv v8, v8, v10 +; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v8, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i16 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = zext %splat to + %x = lshr %va, %vb + %y = trunc %x to + ret %y +} + +define @vnsrl_wx_i8_nxv1i32_zext( %va, i8 %b) { +; CHECK-LABEL: vnsrl_wx_i8_nxv1i32_zext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, mf8, ta, ma +; CHECK-NEXT: vmv.v.x v9, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, ma +; CHECK-NEXT: vsext.vf8 v10, v9 +; CHECK-NEXT: vsrl.vv v8, v8, v10 +; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v8, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i8 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = sext %splat to + %x = lshr %va, %vb + %y = trunc %x to + ret %y +} + define @vnsrl_wi_i32_nxv1i32_zext( %va) { ; CHECK-LABEL: vnsrl_wi_i32_nxv1i32_zext: ; CHECK: # %bb.0: @@ -241,6 +491,44 @@ ret %y } +define @vnsrl_wx_i16_nxv2i32_zext( %va, i16 %b) { +; CHECK-LABEL: vnsrl_wx_i16_nxv2i32_zext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma +; CHECK-NEXT: vmv.v.x v10, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma +; CHECK-NEXT: vzext.vf4 v12, v10 +; CHECK-NEXT: vsrl.vv v10, v8, v12 +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v10, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i16 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = zext %splat to + %x = lshr %va, %vb + %y = trunc %x to + ret %y +} + +define @vnsrl_wx_i8_nxv2i32_zext( %va, i8 %b) { +; CHECK-LABEL: vnsrl_wx_i8_nxv2i32_zext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma +; CHECK-NEXT: vmv.v.x v10, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma +; CHECK-NEXT: vsext.vf8 v12, v10 +; CHECK-NEXT: vsrl.vv v10, v8, v12 +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v10, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i8 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = sext %splat to + %x = lshr %va, %vb + %y = trunc %x to + ret %y +} + define @vnsrl_wi_i32_nxv2i32_zext( %va) { ; CHECK-LABEL: vnsrl_wi_i32_nxv2i32_zext: ; CHECK: # %bb.0: @@ -284,6 +572,44 @@ ret %y } +define @vnsrl_wx_i16_nxv4i32_zext( %va, i16 %b) { +; CHECK-LABEL: vnsrl_wx_i16_nxv4i32_zext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, ma +; CHECK-NEXT: vmv.v.x v12, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, ma +; CHECK-NEXT: vzext.vf4 v16, v12 +; CHECK-NEXT: vsrl.vv v12, v8, v16 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v12, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i16 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = zext %splat to + %x = lshr %va, %vb + %y = trunc %x to + ret %y +} + +define @vnsrl_wx_i8_nxv4i32_zext( %va, i8 %b) { +; CHECK-LABEL: vnsrl_wx_i8_nxv4i32_zext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma +; CHECK-NEXT: vmv.v.x v12, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, ma +; CHECK-NEXT: vsext.vf8 v16, v12 +; CHECK-NEXT: vsrl.vv v12, v8, v16 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v12, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i8 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = sext %splat to + %x = lshr %va, %vb + %y = trunc %x to + ret %y +} + define @vnsrl_wi_i32_nxv4i32_zext( %va) { ; CHECK-LABEL: vnsrl_wi_i32_nxv4i32_zext: ; CHECK: # %bb.0: @@ -327,6 +653,44 @@ ret %y } +define @vnsrl_wx_i16_nxv8i32_zext( %va, i16 %b) { +; CHECK-LABEL: vnsrl_wx_i16_nxv8i32_zext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma +; CHECK-NEXT: vmv.v.x v16, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma +; CHECK-NEXT: vzext.vf4 v24, v16 +; CHECK-NEXT: vsrl.vv v16, v8, v24 +; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v16, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i16 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = zext %splat to + %x = lshr %va, %vb + %y = trunc %x to + ret %y +} + +define @vnsrl_wx_i8_nxv8i32_zext( %va, i8 %b) { +; CHECK-LABEL: vnsrl_wx_i8_nxv8i32_zext: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, ma +; CHECK-NEXT: vmv.v.x v16, a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma +; CHECK-NEXT: vsext.vf8 v24, v16 +; CHECK-NEXT: vsrl.vv v16, v8, v24 +; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma +; CHECK-NEXT: vnsrl.wi v8, v16, 0 +; CHECK-NEXT: ret + %head = insertelement poison, i8 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vb = sext %splat to + %x = lshr %va, %vb + %y = trunc %x to + ret %y +} + define @vnsrl_wi_i32_nxv8i32_zext( %va) { ; CHECK-LABEL: vnsrl_wi_i32_nxv8i32_zext: ; CHECK: # %bb.0: