Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp =================================================================== --- llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp +++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp @@ -138,7 +138,7 @@ std::pair RISCVVType::decodeVLMUL(RISCVII::VLMUL VLMUL) { switch (VLMUL) { default: - llvm_unreachable("Unexpected LMUL value!"); + return std::make_pair(0, false); case RISCVII::VLMUL::LMUL_1: case RISCVII::VLMUL::LMUL_2: case RISCVII::VLMUL::LMUL_4: @@ -159,11 +159,12 @@ bool Fractional; std::tie(LMul, Fractional) = decodeVLMUL(getVLMUL(VType)); - if (Fractional) - OS << ", mf"; + if (LMul == 0) + OS << ", "; + else if (Fractional) + OS << ", mf" << LMul; else - OS << ", m"; - OS << LMul; + OS << ", m" << LMul; if (isTailAgnostic(VType)) OS << ", ta"; Index: llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp =================================================================== --- llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp +++ llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp @@ -155,6 +155,7 @@ unsigned LMul; bool Fractional; std::tie(LMul, Fractional) = RISCVVType::decodeVLMUL(VLMul); + assert(LMul != 0 && "Reserved LMUL value"); // Convert LMul to a fixed point value with 3 fractional bits. LMul = Fractional ? (8 / LMul) : (LMul * 8); Index: llvm/lib/Target/RISCV/RISCVInstrInfo.cpp =================================================================== --- llvm/lib/Target/RISCV/RISCVInstrInfo.cpp +++ llvm/lib/Target/RISCV/RISCVInstrInfo.cpp @@ -409,6 +409,7 @@ unsigned LMulVal; bool Fractional; std::tie(LMulVal, Fractional) = RISCVVType::decodeVLMUL(LMul); + assert(LMulVal != 0 && "Reserved LMUL value"); assert(!Fractional && "It is impossible be fractional lmul here."); if (forwardCopyWillClobberTuple(DstEncoding, SrcEncoding, NF * LMulVal)) { I = NF - 1; Index: llvm/test/tools/llvm-objdump/RISCV/vsetvli.test =================================================================== --- /dev/null +++ llvm/test/tools/llvm-objdump/RISCV/vsetvli.test @@ -0,0 +1,5 @@ +// RUN: llvm-objdump -D --mattr=+experimental-v %p/Inputs/vsetvli.o | FileCheck --check-prefix=CHECK %s + +# CHECK: 0: d7 75 85 01 vsetvli a1, a0, e64, m1, tu, mu +# CHECK: 4: d7 75 c5 01 vsetvli a1, a0, e64, , tu, mu +# CHECK: 8: d7 75 d5 01 vsetvli a1, a0, e64, mf8, tu, mu