diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp index f1ce430f3323..95ea4528e2ad 100644 --- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -825,7 +825,7 @@ private: bool ParseIntelDotOperator(IntelExprStateMachine &SM, SMLoc &End); unsigned IdentifyIntelInlineAsmOperator(StringRef Name); unsigned ParseIntelInlineAsmOperator(unsigned OpKind); - std::unique_ptr ParseRoundingModeOp(SMLoc Start, SMLoc End); + std::unique_ptr ParseRoundingModeOp(SMLoc Start); bool ParseIntelNamedOperator(StringRef Name, IntelExprStateMachine &SM); void RewriteIntelExpression(IntelExprStateMachine &SM, SMLoc Start, SMLoc End); @@ -1595,7 +1595,7 @@ bool X86AsmParser::ParseIntelInlineAsmIdentifier(const MCExpr *&Val, //ParseRoundingModeOp - Parse AVX-512 rounding mode operand std::unique_ptr -X86AsmParser::ParseRoundingModeOp(SMLoc Start, SMLoc End) { +X86AsmParser::ParseRoundingModeOp(SMLoc Start) { MCAsmParser &Parser = getParser(); const AsmToken &Tok = Parser.getTok(); // Eat "{" and mark the current place. @@ -1616,6 +1616,7 @@ X86AsmParser::ParseRoundingModeOp(SMLoc Start, SMLoc End) { Parser.Lex(); // Eat the sae if (!getLexer().is(AsmToken::RCurly)) return ErrorOperand(Tok.getLoc(), "Expected } at this point"); + SMLoc End = Tok.getEndLoc(); Parser.Lex(); // Eat "}" const MCExpr *RndModeOp = MCConstantExpr::create(rndMode, Parser.getContext()); @@ -1794,7 +1795,7 @@ std::unique_ptr X86AsmParser::ParseIntelOperand() { // Rounding mode operand. if (getSTI().getFeatureBits()[X86::FeatureAVX512] && getLexer().is(AsmToken::LCurly)) - return ParseRoundingModeOp(Start, End); + return ParseRoundingModeOp(Start); // Register operand. unsigned RegNo = 0; @@ -1895,9 +1896,9 @@ std::unique_ptr X86AsmParser::ParseATTOperand() { return X86Operand::CreateImm(Val, Start, End); } case AsmToken::LCurly:{ - SMLoc Start = Parser.getTok().getLoc(), End; + SMLoc Start = Parser.getTok().getLoc(); if (getSTI().getFeatureBits()[X86::FeatureAVX512]) - return ParseRoundingModeOp(Start, End); + return ParseRoundingModeOp(Start); return ErrorOperand(Start, "Unexpected '{' in expression"); } } diff --git a/llvm/test/MC/X86/avx512-err.s b/llvm/test/MC/X86/avx512-err.s index b9eb3711c05e..329d851cd5db 100644 --- a/llvm/test/MC/X86/avx512-err.s +++ b/llvm/test/MC/X86/avx512-err.s @@ -8,3 +8,6 @@ vfmsub213ps %zmm8, %zmm8, %zmm8{%k2} {rn-sae} // ERR: Expected an op-mask register at this point vfmsub213ps %zmm8, %zmm8, %zmm8 {rn-sae} + +// ERR: invalid operand for instruction +cvtsd2sil {rn-sae}, %xmm1, %eax