Index: lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp =================================================================== --- lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp +++ lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp @@ -2919,6 +2919,7 @@ if (getLexer().isNot(AsmToken::Integer)) return true; + SMLoc ValLoc = Parser.getTok().getLoc(); if (getParser().parseAbsoluteExpression(CntVal)) return true; @@ -2936,21 +2937,24 @@ Failed = encodeCnt(ISA, IntVal, CntVal, Sat, encodeLgkmcnt, decodeLgkmcnt); } - // To improve diagnostics, do not skip delimiters on errors - if (!Failed) { - if (getLexer().isNot(AsmToken::RParen)) { - return true; - } - Parser.Lex(); - if (getLexer().is(AsmToken::Amp) || getLexer().is(AsmToken::Comma)) { - const AsmToken NextToken = getLexer().peekTok(); - if (NextToken.is(AsmToken::Identifier)) { - Parser.Lex(); - } + if (Failed) { + Error(ValLoc, "too large value for " + CntName); + return true; + } + + if (getLexer().isNot(AsmToken::RParen)) { + return true; + } + + Parser.Lex(); + if (getLexer().is(AsmToken::Amp) || getLexer().is(AsmToken::Comma)) { + const AsmToken NextToken = getLexer().peekTok(); + if (NextToken.is(AsmToken::Identifier)) { + Parser.Lex(); } } - return Failed; + return false; } OperandMatchResultTy Index: test/MC/AMDGPU/sopp-err.s =================================================================== --- test/MC/AMDGPU/sopp-err.s +++ test/MC/AMDGPU/sopp-err.s @@ -75,16 +75,16 @@ // GCN: error: invalid/unsupported code of SYSMSG_OP s_waitcnt lgkmcnt(16) -// GCN: error: failed parsing operand +// GCN: error: too large value for lgkmcnt s_waitcnt expcnt(8) -// GCN: error: failed parsing operand +// GCN: error: too large value for expcnt s_waitcnt vmcnt(16) -// GCN: error: failed parsing operand +// GCN: error: too large value for vmcnt s_waitcnt vmcnt(0xFFFFFFFFFFFF0000) -// GCN: error: failed parsing operand +// GCN: error: too large value for vmcnt s_waitcnt vmcnt(0), expcnt(0), lgkmcnt(0), // GCN: error: failed parsing operand