diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp --- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp +++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp @@ -4942,9 +4942,6 @@ Mode = OperandMode_NSA; OperandMatchResultTy Res = parseOperand(Operands, Name, Mode); - // Eat the comma or space if there is one. - trySkipToken(AsmToken::Comma); - if (Res != MatchOperand_Success) { checkUnsupportedInstruction(Name, NameLoc); if (!Parser.hasPendingError()) { @@ -4959,6 +4956,9 @@ } return true; } + + // Eat the comma or space if there is one. + trySkipToken(AsmToken::Comma); } return false; diff --git a/llvm/test/MC/AMDGPU/gfx10_err_pos.s b/llvm/test/MC/AMDGPU/gfx10_err_pos.s --- a/llvm/test/MC/AMDGPU/gfx10_err_pos.s +++ b/llvm/test/MC/AMDGPU/gfx10_err_pos.s @@ -535,6 +535,11 @@ // CHECK-NEXT:{{^}}v_ceil_f16 v0, abs(neg(1)) // CHECK-NEXT:{{^}} ^ +image_atomic_xor v4, v32, s[96:103] dmask:0x1 dim:, glc +// CHECK: error: failed parsing operand. +// CHECK-NEXT:{{^}}image_atomic_xor v4, v32, s[96:103] dmask:0x1 dim:, glc +// CHECK-NEXT:{{^}} ^ + //============================================================================== // first register index should not exceed second index