Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp =================================================================== --- llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp +++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp @@ -170,6 +170,12 @@ void RISCVInstPrinter::printVTypeI(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O) { unsigned Imm = MI->getOperand(OpNo).getImm(); + // The encoding vlmul[2:0]=4 is reserved, so we just print the immediate. + if ((Imm & 7) == 4) { + O << Imm; + return; + } + // Print the text form. RISCVVType::printVType(Imm, O); } Index: llvm/test/MC/RISCV/rvv/vsetvl-invalid.s =================================================================== --- /dev/null +++ llvm/test/MC/RISCV/rvv/vsetvl-invalid.s @@ -0,0 +1,28 @@ +# RUN: llvm-mc -filetype=obj -triple=riscv32 %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-v - | FileCheck %s +# RUN: llvm-mc -filetype=obj -triple=riscv64 %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-v - | FileCheck %s + +# CHECK: vsetvli a1, a0, e64, m1, tu, mu +.word 0x018575d7 + +# CHECK: vsetvli a1, a0, 28 +.word 0x01c575d7 + +# CHECK: vsetvli a1, a0, 36 +.word 0x024575d7 + +# CHECK: vsetvli a1, a0, e64, mf8, tu, mu +.word 0x01d575d7 + +# CHECK: vsetivli a1, 16, e8, m4, tu, mu +.word 0xc02875d7 + +# CHECK: vsetivli a1, 16, 12 +.word 0xc0c875d7 + +# CHECK: vsetivli a1, 16, 52 +.word 0xc34875d7 + +# CHECK: vsetivli a1, 16, e8, mf4, tu, mu +.word 0xc06875d7