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,95 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs < %s | FileCheck %s + +declare @llvm.riscv.vmset.nxv1i1(i64); + +declare @llvm.riscv.vadd.mask.nxv1i8.nxv1i8( + , + , + , + , + i64, i64); + +; Use unmasked instruction because the mask operand is allone mask; +define @test0( %0, %1, i64 %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( + i64 %2); + %a = call @llvm.riscv.vadd.mask.nxv1i8.nxv1i8( + undef, + %0, + %1, + %allone, + i64 %2, i64 1) + + ret %a +} + +; Regardless of the policy operand, TAIL_AGNOSIC is used because the tie operand is IMPLICIT_DEF +define @test1( %0, %1, i64 %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( + i64 %2); + %a = call @llvm.riscv.vadd.mask.nxv1i8.nxv1i8( + undef, + %0, + %1, + %allone, + i64 %2, i64 0) + + ret %a +} + +; Merge operand is kept because of the policy operand +define @test2( %0, %1, %2, i64 %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( + i64 %3); + %a = call @llvm.riscv.vadd.mask.nxv1i8.nxv1i8( + %0, + %1, + %2, + %allone, + i64 %3, i64 0) + + ret %a +} + +; Merge operand is dropped because of the policy operand +define @test3( %0, %1, %2, i64 %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( + i64 %3); + %a = call @llvm.riscv.vadd.mask.nxv1i8.nxv1i8( + %0, + %1, + %2, + %allone, + i64 %3, i64 1) + + ret %a +}