Index: lib/Target/X86/AsmParser/X86AsmParser.cpp =================================================================== --- lib/Target/X86/AsmParser/X86AsmParser.cpp +++ lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -2089,14 +2089,17 @@ // no errors. // Query for the need of further parsing for a {%k} mark if (!Z || getLexer().is(AsmToken::LCurly)) { - const SMLoc StartLoc = Z ? consumeToken() : consumedToken; + SMLoc StartLoc = Z ? consumeToken() : consumedToken; // Parse an op-mask register mark ({%k}), which is now to be // expected - if (std::unique_ptr Op = ParseOperand()) { + unsigned RegNo; + if (!ParseRegister(RegNo, StartLoc, StartLoc) && + X86MCRegisterClasses[X86::VK1RegClassID].contains(RegNo)) { if (!getLexer().is(AsmToken::RCurly)) return Error(getLexer().getLoc(), "Expected } at this point"); Operands.push_back(X86Operand::CreateToken("{", StartLoc)); - Operands.push_back(std::move(Op)); + Operands.push_back(std::move(X86Operand::CreateReg(RegNo, StartLoc, + StartLoc))); Operands.push_back(X86Operand::CreateToken("}", consumeToken())); } else return Error(getLexer().getLoc(), @@ -2106,7 +2109,8 @@ // Have we've found a parsing error, or found no (expected) {z} mark // - report an error if (ParseZ(Z, consumeToken()) || !Z) - return true; + return Error(getLexer().getLoc(), + "Expected a {z} mark at this point"); } // '{z}' on its own is meaningless, hence should be ignored. Index: test/MC/X86/avx512-err.s =================================================================== --- test/MC/X86/avx512-err.s +++ test/MC/X86/avx512-err.s @@ -1,6 +1,11 @@ -// RUN: not llvm-mc -triple x86_64-unknown-unknown -mcpu=knl -mattr=+avx512dq --show-encoding %s 2> %t.err +// RUN: not llvm-mc -triple x86_64-unknown-unknown -mcpu=knl -mattr=+avx512dq -mattr=+avx512f --show-encoding %s 2> %t.err // RUN: FileCheck --check-prefix=ERR < %t.err %s // ERR: invalid operand for instruction vpcmpd $1, %zmm24, %zmm7, %k5{%k0} +// ERR: Expected a {z} mark at this point +vfmsub213ps %zmm8, %zmm8, %zmm8{%k2} {rn-sae} + +// ERR: Expected an op-mask register at this point +vfmsub213ps %zmm8, %zmm8, %zmm8 {rn-sae} Index: test/MC/X86/intel-syntax-avx512-error.s =================================================================== --- test/MC/X86/intel-syntax-avx512-error.s +++ test/MC/X86/intel-syntax-avx512-error.s @@ -0,0 +1,9 @@ +// RUN: llvm-mc %s -triple x86_64-unknown-unknown -mcpu=knl -mattr=+avx512f -x86-asm-syntax=intel -output-asm-variant=1 -o /dev/null 2>&1 | FileCheck %s + +// Validate that only OpMask/Zero mark may immediately follow destination + vfmsub213ps zmm8{rn-sae} {k2}, zmm8, zmm8 +// CHECK: error: Expected an op-mask register at this point + vfmsub213ps zmm8{k2} {rn-sae}, zmm8, zmm8 +// CHECK: error: Expected a {z} mark at this point + vfmsub213ps zmm8{rn-sae}, zmm8, zmm8 +// CHECK: error: Expected an op-mask register at this point