diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp --- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -2461,6 +2461,17 @@ bool RISCVAsmParser::validateInstruction(MCInst &Inst, OperandVector &Operands) { + if (Inst.getOpcode() == RISCV::PseudoVMSGEU_VX_M_T || + Inst.getOpcode() == RISCV::PseudoVMSGE_VX_M_T) { + unsigned DestReg = Inst.getOperand(0).getReg(); + unsigned TempReg = Inst.getOperand(1).getReg(); + if (DestReg == TempReg) { + SMLoc Loc = Operands.back()->getStartLoc(); + return Error(Loc, "The temporary vector register cannot be the same as " + "the destination register."); + } + } + const MCInstrDesc &MCID = MII.get(Inst.getOpcode()); unsigned Constraints = (MCID.TSFlags & RISCVII::ConstraintMask) >> RISCVII::ConstraintShift; diff --git a/llvm/test/MC/RISCV/rvv/invalid.s b/llvm/test/MC/RISCV/rvv/invalid.s --- a/llvm/test/MC/RISCV/rvv/invalid.s +++ b/llvm/test/MC/RISCV/rvv/invalid.s @@ -666,3 +666,9 @@ vmsgeu.vx v2, v4, a0, v0.t, v0 # CHECK-ERROR: invalid operand for instruction + +vmsge.vx v2, v4, a0, v0.t, v2 +# CHECK-ERROR: The temporary vector register cannot be the same as the destination register. + +vmsgeu.vx v2, v4, a0, v0.t, v2 +# CHECK-ERROR: The temporary vector register cannot be the same as the destination register.