diff --git a/llvm/test/CodeGen/RISCV/rvv/allone-masked-to-unmasked.ll b/llvm/test/CodeGen/RISCV/rvv/allone-masked-to-unmasked.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv/allone-masked-to-unmasked.ll @@ -0,0 +1,96 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+v -verify-machineinstrs | FileCheck %s +; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs | FileCheck %s + +declare @llvm.riscv.vmset.nxv1i1(iXLen); + +declare @llvm.riscv.vadd.mask.nxv1i8.nxv1i8( + , + , + , + , + iXLen, iXLen); + +; Use unmasked instruction because the mask operand is allone mask +define @test0( %0, %1, iXLen %2) nounwind { +; CHECK-LABEL: test0: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: vsetvli zero, a0, e8, mf8, ta, mu +; CHECK-NEXT: vadd.vv v8, v8, v9 +; CHECK-NEXT: ret +entry: + %allone = call @llvm.riscv.vmset.nxv1i1( + iXLen %2); + %a = call @llvm.riscv.vadd.mask.nxv1i8.nxv1i8( + undef, + %0, + %1, + %allone, + iXLen %2, iXLen 1) + + ret %a +} + +; FIXME: Use an unmasked TAIL_AGNOSTIC instruction if the tie operand is IMPLICIT_DEF +define @test1( %0, %1, iXLen %2) nounwind { +; CHECK-LABEL: test1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: vsetvli zero, a0, e8, mf8, ta, mu +; CHECK-NEXT: vmset.m v0 +; CHECK-NEXT: vsetvli zero, zero, e8, mf8, tu, mu +; CHECK-NEXT: vadd.vv v8, v8, v9, v0.t +; CHECK-NEXT: ret +entry: + %allone = call @llvm.riscv.vmset.nxv1i1( + iXLen %2); + %a = call @llvm.riscv.vadd.mask.nxv1i8.nxv1i8( + undef, + %0, + %1, + %allone, + iXLen %2, iXLen 0) + + ret %a +} + +; FIXME: Use an unmasked TU instruction because of the policy operand +define @test2( %0, %1, %2, iXLen %3) nounwind { +; CHECK-LABEL: test2: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: vsetvli zero, a0, e8, mf8, ta, mu +; CHECK-NEXT: vmset.m v0 +; CHECK-NEXT: vsetvli zero, zero, e8, mf8, tu, mu +; CHECK-NEXT: vadd.vv v8, v9, v10, v0.t +; CHECK-NEXT: ret +entry: + %allone = call @llvm.riscv.vmset.nxv1i1( + iXLen %3); + %a = call @llvm.riscv.vadd.mask.nxv1i8.nxv1i8( + %0, + %1, + %2, + %allone, + iXLen %3, iXLen 0) + + ret %a +} + +; Merge operand is dropped because of the policy operand +define @test3( %0, %1, %2, iXLen %3) nounwind { +; CHECK-LABEL: test3: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: vsetvli zero, a0, e8, mf8, ta, mu +; CHECK-NEXT: vadd.vv v8, v9, v10 +; CHECK-NEXT: ret +entry: + %allone = call @llvm.riscv.vmset.nxv1i1( + iXLen %3); + %a = call @llvm.riscv.vadd.mask.nxv1i8.nxv1i8( + %0, + %1, + %2, + %allone, + iXLen %3, iXLen 1) + + ret %a +}