diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td @@ -33,6 +33,21 @@ def SplatPat_simm5 : ComplexPattern; def SplatPat_uimm5 : ComplexPattern; +def masked_load : + PatFrag<(ops node:$ptr, node:$mask, node:$maskedoff), + (masked_ld node:$ptr, undef, node:$mask, node:$maskedoff), [{ + return !cast(N)->isExpandingLoad() && + cast(N)->getExtensionType() == ISD::NON_EXTLOAD && + cast(N)->isUnindexed(); +}]>; +def masked_store : + PatFrag<(ops node:$val, node:$ptr, node:$mask), + (masked_st node:$val, node:$ptr, undef, node:$mask), [{ + return !cast(N)->isTruncatingStore() && + !cast(N)->isCompressingStore() && + cast(N)->isUnindexed(); +}]>; + class SwapHelper { dag Value = !con(Prefix, !if(swap, B, A), !if(swap, A, B), Suffix); } @@ -53,6 +68,25 @@ (store_instr reg_class:$rs2, BaseAddr:$rs1, avl, sew)>; } +multiclass VPatUSLoadStoreSDNodeMask +{ + defvar load_instr = !cast("PseudoVLE"#sew#"_V_"#vlmul.MX#"_MASK"); + defvar store_instr = !cast("PseudoVSE"#sew#"_V_"#vlmul.MX#"_MASK"); + // Load + def : Pat<(type (masked_load BaseAddr:$rs1, (mask_type V0), type:$merge)), + (load_instr reg_class:$merge, BaseAddr:$rs1, (mask_type V0), + avl, sew)>; + // Store + def : Pat<(masked_store type:$rs2, BaseAddr:$rs1, (mask_type V0)), + (store_instr reg_class:$rs2, BaseAddr:$rs1, (mask_type V0), + avl, sew)>; +} + multiclass VPatUSLoadStoreWholeVRSDNode; +foreach vti = AllVectors in + defm "" : VPatUSLoadStoreSDNodeMask; foreach vti = [VI8M1, VI16M1, VI32M1, VI64M1, VF16M1, VF32M1, VF64M1] in defm "" : VPatUSLoadStoreWholeVRSDNode; diff --git a/llvm/test/CodeGen/RISCV/rvv/masked-load-fp.ll b/llvm/test/CodeGen/RISCV/rvv/masked-load-fp.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv/masked-load-fp.ll @@ -0,0 +1,168 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=riscv32 -mattr=+d,+experimental-zfh,+experimental-v -target-abi=ilp32d -verify-machineinstrs < %s | FileCheck %s +; RUN: llc -mtriple=riscv64 -mattr=+d,+experimental-zfh,+experimental-v -target-abi=lp64d -verify-machineinstrs < %s | FileCheck %s + +define @masked_load_nxv1f16(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv1f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,mf4,ta,mu +; CHECK-NEXT: vle16.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv1f16(* %a, i32 2, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv1f16(*, i32, , ) + +define @masked_load_nxv1f32(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv1f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,mf2,ta,mu +; CHECK-NEXT: vle32.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv1f32(* %a, i32 4, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv1f32(*, i32, , ) + +define @masked_load_nxv1f64(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv1f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m1,ta,mu +; CHECK-NEXT: vle64.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv1f64(* %a, i32 8, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv1f64(*, i32, , ) + +define @masked_load_nxv2f16(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv2f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,mf2,ta,mu +; CHECK-NEXT: vle16.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv2f16(* %a, i32 2, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv2f16(*, i32, , ) + +define @masked_load_nxv2f32(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv2f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m1,ta,mu +; CHECK-NEXT: vle32.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv2f32(* %a, i32 4, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv2f32(*, i32, , ) + +define @masked_load_nxv2f64(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv2f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m2,ta,mu +; CHECK-NEXT: vle64.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv2f64(* %a, i32 8, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv2f64(*, i32, , ) + +define @masked_load_nxv4f16(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv4f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m1,ta,mu +; CHECK-NEXT: vle16.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv4f16(* %a, i32 2, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv4f16(*, i32, , ) + +define @masked_load_nxv4f32(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv4f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m2,ta,mu +; CHECK-NEXT: vle32.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv4f32(* %a, i32 4, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv4f32(*, i32, , ) + +define @masked_load_nxv4f64(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv4f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m4,ta,mu +; CHECK-NEXT: vle64.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv4f64(* %a, i32 8, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv4f64(*, i32, , ) + +define @masked_load_nxv8f16(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv8f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m2,ta,mu +; CHECK-NEXT: vle16.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv8f16(* %a, i32 2, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv8f16(*, i32, , ) + +define @masked_load_nxv8f32(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv8f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m4,ta,mu +; CHECK-NEXT: vle32.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv8f32(* %a, i32 4, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv8f32(*, i32, , ) + +define @masked_load_nxv8f64(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv8f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m8,tu,mu +; CHECK-NEXT: vle64.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv8f64(* %a, i32 8, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv8f64(*, i32, , ) + +define @masked_load_nxv16f16(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv16f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m4,ta,mu +; CHECK-NEXT: vle16.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv16f16(* %a, i32 2, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv16f16(*, i32, , ) + +define @masked_load_nxv16f32(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv16f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m8,tu,mu +; CHECK-NEXT: vle32.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv16f32(* %a, i32 4, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv16f32(*, i32, , ) + +define @masked_load_nxv32f16(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv32f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m8,tu,mu +; CHECK-NEXT: vle16.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv32f16(* %a, i32 2, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv32f16(*, i32, , ) diff --git a/llvm/test/CodeGen/RISCV/rvv/masked-load-int.ll b/llvm/test/CodeGen/RISCV/rvv/masked-load-int.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv/masked-load-int.ll @@ -0,0 +1,245 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=riscv32 -mattr=+experimental-v -verify-machineinstrs < %s | FileCheck %s +; RUN: llc -mtriple=riscv64 -mattr=+experimental-v -verify-machineinstrs < %s | FileCheck %s + +define @masked_load_nxv1i8(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv1i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,mf8,ta,mu +; CHECK-NEXT: vle8.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv1i8(* %a, i32 1, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv1i8(*, i32, , ) + +define @masked_load_nxv1i16(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv1i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,mf4,ta,mu +; CHECK-NEXT: vle16.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv1i16(* %a, i32 2, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv1i16(*, i32, , ) + +define @masked_load_nxv1i32(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv1i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,mf2,ta,mu +; CHECK-NEXT: vle32.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv1i32(* %a, i32 4, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv1i32(*, i32, , ) + +define @masked_load_nxv1i64(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv1i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m1,ta,mu +; CHECK-NEXT: vle64.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv1i64(* %a, i32 8, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv1i64(*, i32, , ) + +define @masked_load_nxv2i8(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv2i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,mf4,ta,mu +; CHECK-NEXT: vle8.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv2i8(* %a, i32 1, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv2i8(*, i32, , ) + +define @masked_load_nxv2i16(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv2i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,mf2,ta,mu +; CHECK-NEXT: vle16.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv2i16(* %a, i32 2, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv2i16(*, i32, , ) + +define @masked_load_nxv2i32(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv2i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m1,ta,mu +; CHECK-NEXT: vle32.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv2i32(* %a, i32 4, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv2i32(*, i32, , ) + +define @masked_load_nxv2i64(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv2i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m2,ta,mu +; CHECK-NEXT: vle64.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv2i64(* %a, i32 8, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv2i64(*, i32, , ) + +define @masked_load_nxv4i8(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv4i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,mf2,ta,mu +; CHECK-NEXT: vle8.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv4i8(* %a, i32 1, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv4i8(*, i32, , ) + +define @masked_load_nxv4i16(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv4i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m1,ta,mu +; CHECK-NEXT: vle16.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv4i16(* %a, i32 2, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv4i16(*, i32, , ) + +define @masked_load_nxv4i32(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv4i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m2,ta,mu +; CHECK-NEXT: vle32.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv4i32(* %a, i32 4, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv4i32(*, i32, , ) + +define @masked_load_nxv4i64(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv4i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m4,ta,mu +; CHECK-NEXT: vle64.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv4i64(* %a, i32 8, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv4i64(*, i32, , ) + +define @masked_load_nxv8i8(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv8i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,m1,ta,mu +; CHECK-NEXT: vle8.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv8i8(* %a, i32 1, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv8i8(*, i32, , ) + +define @masked_load_nxv8i16(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv8i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m2,ta,mu +; CHECK-NEXT: vle16.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv8i16(* %a, i32 2, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv8i16(*, i32, , ) + +define @masked_load_nxv8i32(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m4,ta,mu +; CHECK-NEXT: vle32.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv8i32(* %a, i32 4, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv8i32(*, i32, , ) + +define @masked_load_nxv8i64(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv8i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m8,tu,mu +; CHECK-NEXT: vle64.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv8i64(* %a, i32 8, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv8i64(*, i32, , ) + +define @masked_load_nxv16i8(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv16i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,m2,ta,mu +; CHECK-NEXT: vle8.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv16i8(* %a, i32 1, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv16i8(*, i32, , ) + +define @masked_load_nxv16i16(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv16i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m4,ta,mu +; CHECK-NEXT: vle16.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv16i16(* %a, i32 2, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv16i16(*, i32, , ) + +define @masked_load_nxv16i32(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv16i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m8,tu,mu +; CHECK-NEXT: vle32.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv16i32(* %a, i32 4, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv16i32(*, i32, , ) + +define @masked_load_nxv32i8(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv32i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,m4,ta,mu +; CHECK-NEXT: vle8.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv32i8(* %a, i32 1, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv32i8(*, i32, , ) + +define @masked_load_nxv32i16(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv32i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m8,tu,mu +; CHECK-NEXT: vle16.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv32i16(* %a, i32 2, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv32i16(*, i32, , ) + +define @masked_load_nxv64i8(* %a, %mask) nounwind { +; CHECK-LABEL: masked_load_nxv64i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,m8,tu,mu +; CHECK-NEXT: vle8.v v8, (a0), v0.t +; CHECK-NEXT: ret + %load = call @llvm.masked.load.nxv64i8(* %a, i32 1, %mask, undef) + ret %load +} +declare @llvm.masked.load.nxv64i8(*, i32, , ) diff --git a/llvm/test/CodeGen/RISCV/rvv/masked-store-fp.ll b/llvm/test/CodeGen/RISCV/rvv/masked-store-fp.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv/masked-store-fp.ll @@ -0,0 +1,168 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=riscv32 -mattr=+d,+experimental-zfh,+experimental-v -target-abi=ilp32d -verify-machineinstrs < %s | FileCheck %s +; RUN: llc -mtriple=riscv64 -mattr=+d,+experimental-zfh,+experimental-v -target-abi=lp64d -verify-machineinstrs < %s | FileCheck %s + +define void @masked_store_nxv1f16( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv1f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,mf4,ta,mu +; CHECK-NEXT: vse16.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.nxv1f16.p0nxv1f16( %val, * %a, i32 2, %mask) + ret void +} +declare void @llvm.masked.store.nxv1f16.p0nxv1f16(, *, i32, ) + +define void @masked_store_nxv1f32( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv1f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,mf2,ta,mu +; CHECK-NEXT: vse32.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.nxv1f32.p0nxv1f32( %val, * %a, i32 4, %mask) + ret void +} +declare void @llvm.masked.store.nxv1f32.p0nxv1f32(, *, i32, ) + +define void @masked_store_nxv1f64( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv1f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m1,ta,mu +; CHECK-NEXT: vse64.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.nxv1f64.p0nxv1f64( %val, * %a, i32 8, %mask) + ret void +} +declare void @llvm.masked.store.nxv1f64.p0nxv1f64(, *, i32, ) + +define void @masked_store_nxv2f16( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv2f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,mf2,ta,mu +; CHECK-NEXT: vse16.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.nxv2f16.p0nxv2f16( %val, * %a, i32 2, %mask) + ret void +} +declare void @llvm.masked.store.nxv2f16.p0nxv2f16(, *, i32, ) + +define void @masked_store_nxv2f32( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv2f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m1,ta,mu +; CHECK-NEXT: vse32.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.nxv2f32.p0nxv2f32( %val, * %a, i32 4, %mask) + ret void +} +declare void @llvm.masked.store.nxv2f32.p0nxv2f32(, *, i32, ) + +define void @masked_store_nxv2f64( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv2f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m2,ta,mu +; CHECK-NEXT: vse64.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.nxv2f64.p0nxv2f64( %val, * %a, i32 8, %mask) + ret void +} +declare void @llvm.masked.store.nxv2f64.p0nxv2f64(, *, i32, ) + +define void @masked_store_nxv4f16( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv4f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m1,ta,mu +; CHECK-NEXT: vse16.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.nxv4f16.p0nxv4f16( %val, * %a, i32 2, %mask) + ret void +} +declare void @llvm.masked.store.nxv4f16.p0nxv4f16(, *, i32, ) + +define void @masked_store_nxv4f32( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv4f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m2,ta,mu +; CHECK-NEXT: vse32.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.nxv4f32.p0nxv4f32( %val, * %a, i32 4, %mask) + ret void +} +declare void @llvm.masked.store.nxv4f32.p0nxv4f32(, *, i32, ) + +define void @masked_store_nxv4f64( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv4f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m4,ta,mu +; CHECK-NEXT: vse64.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.nxv4f64.p0nxv4f64( %val, * %a, i32 8, %mask) + ret void +} +declare void @llvm.masked.store.nxv4f64.p0nxv4f64(, *, i32, ) + +define void @masked_store_nxv8f16( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv8f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m2,ta,mu +; CHECK-NEXT: vse16.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.nxv8f16.p0nxv8f16( %val, * %a, i32 2, %mask) + ret void +} +declare void @llvm.masked.store.nxv8f16.p0nxv8f16(, *, i32, ) + +define void @masked_store_nxv8f32( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv8f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m4,ta,mu +; CHECK-NEXT: vse32.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.nxv8f32.p0nxv8f32( %val, * %a, i32 4, %mask) + ret void +} +declare void @llvm.masked.store.nxv8f32.p0nxv8f32(, *, i32, ) + +define void @masked_store_nxv8f64( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv8f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m8,ta,mu +; CHECK-NEXT: vse64.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.nxv8f64.p0nxv8f64( %val, * %a, i32 8, %mask) + ret void +} +declare void @llvm.masked.store.nxv8f64.p0nxv8f64(, *, i32, ) + +define void @masked_store_nxv16f16( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv16f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m4,ta,mu +; CHECK-NEXT: vse16.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.nxv16f16.p0nxv16f16( %val, * %a, i32 2, %mask) + ret void +} +declare void @llvm.masked.store.nxv16f16.p0nxv16f16(, *, i32, ) + +define void @masked_store_nxv16f32( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv16f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m8,ta,mu +; CHECK-NEXT: vse32.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.nxv16f32.p0nxv16f32( %val, * %a, i32 4, %mask) + ret void +} +declare void @llvm.masked.store.nxv16f32.p0nxv16f32(, *, i32, ) + +define void @masked_store_nxv32f16( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv32f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m8,ta,mu +; CHECK-NEXT: vse16.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.nxv32f16.p0nxv32f16( %val, * %a, i32 2, %mask) + ret void +} +declare void @llvm.masked.store.nxv32f16.p0nxv32f16(, *, i32, ) diff --git a/llvm/test/CodeGen/RISCV/rvv/masked-store-int.ll b/llvm/test/CodeGen/RISCV/rvv/masked-store-int.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv/masked-store-int.ll @@ -0,0 +1,245 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=riscv32 -mattr=+experimental-v -verify-machineinstrs < %s | FileCheck %s +; RUN: llc -mtriple=riscv64 -mattr=+experimental-v -verify-machineinstrs < %s | FileCheck %s + +define void @masked_store_nxv1i8( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv1i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,mf8,ta,mu +; CHECK-NEXT: vse8.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v1i8.p0v1i8( %val, * %a, i32 1, %mask) + ret void +} +declare void @llvm.masked.store.v1i8.p0v1i8(, *, i32, ) + +define void @masked_store_nxv1i16( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv1i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,mf4,ta,mu +; CHECK-NEXT: vse16.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v1i16.p0v1i16( %val, * %a, i32 2, %mask) + ret void +} +declare void @llvm.masked.store.v1i16.p0v1i16(, *, i32, ) + +define void @masked_store_nxv1i32( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv1i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,mf2,ta,mu +; CHECK-NEXT: vse32.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v1i32.p0v1i32( %val, * %a, i32 4, %mask) + ret void +} +declare void @llvm.masked.store.v1i32.p0v1i32(, *, i32, ) + +define void @masked_store_nxv1i64( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv1i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m1,ta,mu +; CHECK-NEXT: vse64.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v1i64.p0v1i64( %val, * %a, i32 8, %mask) + ret void +} +declare void @llvm.masked.store.v1i64.p0v1i64(, *, i32, ) + +define void @masked_store_nxv2i8( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv2i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,mf4,ta,mu +; CHECK-NEXT: vse8.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v2i8.p0v2i8( %val, * %a, i32 1, %mask) + ret void +} +declare void @llvm.masked.store.v2i8.p0v2i8(, *, i32, ) + +define void @masked_store_nxv2i16( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv2i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,mf2,ta,mu +; CHECK-NEXT: vse16.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v2i16.p0v2i16( %val, * %a, i32 2, %mask) + ret void +} +declare void @llvm.masked.store.v2i16.p0v2i16(, *, i32, ) + +define void @masked_store_nxv2i32( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv2i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m1,ta,mu +; CHECK-NEXT: vse32.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v2i32.p0v2i32( %val, * %a, i32 4, %mask) + ret void +} +declare void @llvm.masked.store.v2i32.p0v2i32(, *, i32, ) + +define void @masked_store_nxv2i64( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv2i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m2,ta,mu +; CHECK-NEXT: vse64.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v2i64.p0v2i64( %val, * %a, i32 8, %mask) + ret void +} +declare void @llvm.masked.store.v2i64.p0v2i64(, *, i32, ) + +define void @masked_store_nxv4i8( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv4i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,mf2,ta,mu +; CHECK-NEXT: vse8.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v4i8.p0v4i8( %val, * %a, i32 1, %mask) + ret void +} +declare void @llvm.masked.store.v4i8.p0v4i8(, *, i32, ) + +define void @masked_store_nxv4i16( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv4i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m1,ta,mu +; CHECK-NEXT: vse16.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v4i16.p0v4i16( %val, * %a, i32 2, %mask) + ret void +} +declare void @llvm.masked.store.v4i16.p0v4i16(, *, i32, ) + +define void @masked_store_nxv4i32( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv4i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m2,ta,mu +; CHECK-NEXT: vse32.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v4i32.p0v4i32( %val, * %a, i32 4, %mask) + ret void +} +declare void @llvm.masked.store.v4i32.p0v4i32(, *, i32, ) + +define void @masked_store_nxv4i64( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv4i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m4,ta,mu +; CHECK-NEXT: vse64.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v4i64.p0v4i64( %val, * %a, i32 8, %mask) + ret void +} +declare void @llvm.masked.store.v4i64.p0v4i64(, *, i32, ) + +define void @masked_store_nxv8i8( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv8i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,m1,ta,mu +; CHECK-NEXT: vse8.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v8i8.p0v8i8( %val, * %a, i32 1, %mask) + ret void +} +declare void @llvm.masked.store.v8i8.p0v8i8(, *, i32, ) + +define void @masked_store_nxv8i16( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv8i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m2,ta,mu +; CHECK-NEXT: vse16.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v8i16.p0v8i16( %val, * %a, i32 2, %mask) + ret void +} +declare void @llvm.masked.store.v8i16.p0v8i16(, *, i32, ) + +define void @masked_store_nxv8i32( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m4,ta,mu +; CHECK-NEXT: vse32.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v8i32.p0v8i32( %val, * %a, i32 4, %mask) + ret void +} +declare void @llvm.masked.store.v8i32.p0v8i32(, *, i32, ) + +define void @masked_store_nxv8i64( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv8i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m8,ta,mu +; CHECK-NEXT: vse64.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v8i64.p0v8i64( %val, * %a, i32 8, %mask) + ret void +} +declare void @llvm.masked.store.v8i64.p0v8i64(, *, i32, ) + +define void @masked_store_nxv16i8( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv16i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,m2,ta,mu +; CHECK-NEXT: vse8.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v16i8.p0v16i8( %val, * %a, i32 1, %mask) + ret void +} +declare void @llvm.masked.store.v16i8.p0v16i8(, *, i32, ) + +define void @masked_store_nxv16i16( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv16i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m4,ta,mu +; CHECK-NEXT: vse16.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v16i16.p0v16i16( %val, * %a, i32 2, %mask) + ret void +} +declare void @llvm.masked.store.v16i16.p0v16i16(, *, i32, ) + +define void @masked_store_nxv16i32( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv16i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m8,ta,mu +; CHECK-NEXT: vse32.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v16i32.p0v16i32( %val, * %a, i32 4, %mask) + ret void +} +declare void @llvm.masked.store.v16i32.p0v16i32(, *, i32, ) + +define void @masked_store_nxv32i8( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv32i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,m4,ta,mu +; CHECK-NEXT: vse8.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v32i8.p0v32i8( %val, * %a, i32 1, %mask) + ret void +} +declare void @llvm.masked.store.v32i8.p0v32i8(, *, i32, ) + +define void @masked_store_nxv32i16( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv32i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m8,ta,mu +; CHECK-NEXT: vse16.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v32i16.p0v32i16( %val, * %a, i32 2, %mask) + ret void +} +declare void @llvm.masked.store.v32i16.p0v32i16(, *, i32, ) + +define void @masked_store_nxv64i8( %val, * %a, %mask) nounwind { +; CHECK-LABEL: masked_store_nxv64i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,m8,ta,mu +; CHECK-NEXT: vse8.v v8, (a0), v0.t +; CHECK-NEXT: ret + call void @llvm.masked.store.v64i8.p0v64i8( %val, * %a, i32 4, %mask) + ret void +} +declare void @llvm.masked.store.v64i8.p0v64i8(, *, i32, )