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 @@ -6691,7 +6691,8 @@ addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTyOffset); if (!IsAtomic || IsAtomicReturn) { - addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTyGLC); + addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTyGLC, + IsAtomicReturn ? -1 : 0); } addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySLC); diff --git a/llvm/test/MC/AMDGPU/gfx1030_err.s b/llvm/test/MC/AMDGPU/gfx1030_err.s --- a/llvm/test/MC/AMDGPU/gfx1030_err.s +++ b/llvm/test/MC/AMDGPU/gfx1030_err.s @@ -140,3 +140,9 @@ ds_write_src2_b64 v1 offset:65535 // GFX10: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU + +buffer_atomic_csub v5, off, s[8:11], s3 offset:4095 +// GFX10: :[[@LINE-1]]:{{[0-9]+}}: error: instruction must use glc + +global_atomic_csub v2, v[0:1], v2, off offset:100 slc +// GFX10: :[[@LINE-1]]:{{[0-9]+}}: error: instruction must use glc diff --git a/llvm/test/MC/AMDGPU/gfx1030_new.s b/llvm/test/MC/AMDGPU/gfx1030_new.s --- a/llvm/test/MC/AMDGPU/gfx1030_new.s +++ b/llvm/test/MC/AMDGPU/gfx1030_new.s @@ -27,7 +27,7 @@ global_atomic_csub v2, v0, v2, s[2:3] offset:100 glc slc // GFX10: encoding: [0x64,0x80,0xd3,0xdc,0x00,0x02,0x02,0x02] -buffer_atomic_csub v5, off, s[8:11], s3 +buffer_atomic_csub v5, off, s[8:11], s3 glc // GFX10: encoding: [0x00,0x40,0xd0,0xe0,0x00,0x05,0x02,0x03] buffer_atomic_csub v5, off, s[8:11], s3 offset:4095 glc