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 @@ -1613,9 +1613,11 @@ return MatchOperand_Success; case AsmToken::Plus: Opcode = MCBinaryExpr::Add; + getLexer().Lex(); break; case AsmToken::Minus: Opcode = MCBinaryExpr::Sub; + getLexer().Lex(); break; } diff --git a/llvm/test/MC/RISCV/rvi-pseudos.s b/llvm/test/MC/RISCV/rvi-pseudos.s --- a/llvm/test/MC/RISCV/rvi-pseudos.s +++ b/llvm/test/MC/RISCV/rvi-pseudos.s @@ -187,3 +187,9 @@ # CHECK: auipc a5, %pcrel_hi((255+a_symbol)-4) # CHECK: addi a5, a5, %pcrel_lo(.Lpcrel_hi30) lla a5, (0xFF + a_symbol) - 4 + +## Check that we don't double-parse a top-level minus. +# CHECK: .Lpcrel_hi31: +# CHECK: auipc a5, %pcrel_hi(a_symbol-4) +# CHECK: addi a5, a5, %pcrel_lo(.Lpcrel_hi31) +lla a5, a_symbol - 4