Index: llvm/trunk/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp =================================================================== --- llvm/trunk/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp +++ llvm/trunk/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp @@ -1760,6 +1760,11 @@ // TODO: add syntactic sugar for 1/(2*PI) bool Minus = false; if (getLexer().getKind() == AsmToken::Minus) { + const AsmToken NextToken = getLexer().peekTok(); + if (!NextToken.is(AsmToken::Integer) && + !NextToken.is(AsmToken::Real)) { + return MatchOperand_NoMatch; + } Minus = true; Parser.Lex(); } @@ -1789,7 +1794,7 @@ return MatchOperand_Success; } default: - return Minus ? MatchOperand_ParseFail : MatchOperand_NoMatch; + return MatchOperand_NoMatch; } } Index: llvm/trunk/test/MC/AMDGPU/expressions.s =================================================================== --- llvm/trunk/test/MC/AMDGPU/expressions.s +++ llvm/trunk/test/MC/AMDGPU/expressions.s @@ -46,3 +46,11 @@ s_sub_u32 vcc_lo, vcc_lo, (BB2+4)-BB1 // VI: s_sub_u32 vcc_lo, vcc_lo, (BB2+4)-BB1 ; encoding: [0x6a,0xff,0xea,0x80,A,A,A,A] // VI-NEXT: ; fixup A - offset: 4, value: (BB2+4)-BB1, kind: FK_Data_4 + +t=1 +s_sub_u32 s0, s0, -t +// VI: s_sub_u32 s0, s0, -1 ; encoding: [0x00,0xc1,0x80,0x80] + +t=-1 +s_sub_u32 s0, s0, -t +// VI: s_sub_u32 s0, s0, 1 ; encoding: [0x00,0x81,0x80,0x80] Index: llvm/trunk/test/MC/AMDGPU/vop3p-err.s =================================================================== --- llvm/trunk/test/MC/AMDGPU/vop3p-err.s +++ llvm/trunk/test/MC/AMDGPU/vop3p-err.s @@ -59,16 +59,16 @@ // GFX9: :22: error: invalid operand for instruction v_pk_add_f16 v1, v2, abs(v3) -// GFX9: :19: error: invalid operand for instruction +// GFX9: :18: error: invalid operand for instruction v_pk_add_f16 v1, -v2, v3 -// GFX9: :23: error: invalid operand for instruction +// GFX9: :22: error: invalid operand for instruction v_pk_add_f16 v1, v2, -v3 // GFX9: :18: error: invalid operand for instruction v_pk_add_u16 v1, abs(v2), v3 -// GFX9: :19: error: invalid operand for instruction +// GFX9: :18: error: invalid operand for instruction v_pk_add_u16 v1, -v2, v3 //