Skip to content

Commit 3b88f06

Browse files
committed
Changing two symbolic names to one
1 parent 1cfa633 commit 3b88f06

File tree

6 files changed

+9
-26
lines changed

6 files changed

+9
-26
lines changed

llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,8 +2409,10 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
24092409
case AMDGPU::OPERAND_REG_INLINE_C_BF16:
24102410
case AMDGPU::OPERAND_REG_INLINE_C_V2BF16:
24112411
case AMDGPU::OPERAND_REG_IMM_V2BF16:
2412+
// If the symbol INV2PI is used as the operand, the value is set to
2413+
// 0x3fc45f306dc9c882 in parseImm().
24122414
if (Lit == LitModifier::None && AsmParser->hasInv2PiInlineImm() &&
2413-
Literal == 0x3fc45f306725feed) {
2415+
(Literal == 0x3fc45f306725feed || Literal == 0x3fc45f306dc9c882)) {
24142416
// This is the 1/(2*pi) which is going to be truncated to bf16 with the
24152417
// loss of precision. The constant represents ideomatic fp32 value of
24162418
// 1/(2*pi) = 0.15915494 since bf16 is in fact fp32 with cleared low 16
@@ -3229,10 +3231,7 @@ AMDGPUAsmParser::parseRegister(bool RestoreOnFailure) {
32293231
}
32303232

32313233
static bool isInv2PiToken(const AsmToken &Tok) {
3232-
if (!Tok.is(AsmToken::Identifier))
3233-
return false;
3234-
StringRef Str = Tok.getIdentifier();
3235-
return (Str.str() == "INV2PI" || Str.str() == "INV2PI64");
3234+
return Tok.is(AsmToken::Identifier) && Tok.getIdentifier() == "INV2PI";
32363235
}
32373236

32383237
ParseStatus AMDGPUAsmParser::parseImm(OperandVector &Operands,
@@ -3281,9 +3280,9 @@ ParseStatus AMDGPUAsmParser::parseImm(OperandVector &Operands,
32813280
// optional sign.
32823281

32833282
StringRef Num = getTokenStr();
3284-
if (Num.str() == "INV2PI")
3285-
Num = "0.15915494";
3286-
else if (Num.str() == "INV2PI64")
3283+
if (Num == "INV2PI")
3284+
// Setting the imm to this for INV2PI works for all types except bf16.
3285+
// In addLiteralImmOperand() we specifically check for this.
32873286
Num = "0.15915494309189532";
32883287
lex();
32893288

llvm/test/MC/AMDGPU/bf16_imm-fake16.s

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ v_dot2_f32_bf16 v2, v1, 0.15915494, v2
8383
v_dot2_f32_bf16 v2, v1, INV2PI, v2
8484
// CHECK: v_dot2_f32_bf16 v2, v1, 0.15915494, v2 ; encoding: [0x02,0x40,0x1a,0xcc,0x01,0xf1,0x09,0x1c]
8585

86-
// INV2PI64 is not interpreted as INV2PI
87-
v_dot2_f32_bf16 v2, v1, INV2PI64, v2
88-
// CHECK: v_dot2_f32_bf16 v2, v1, 0x3e23, v2 ; encoding: [0x02,0x40,0x1a,0xcc,0x01,0xff,0x09,0x1c,0x23,0x3e,0x00,0x00]
89-
9086
v_dot2_f32_bf16 v2, v1, 0x3e22, v2
9187
// CHECK: v_dot2_f32_bf16 v2, v1, 0.15915494, v2 ; encoding: [0x02,0x40,0x1a,0xcc,0x01,0xf1,0x09,0x1c]
9288

llvm/test/MC/AMDGPU/gfx1250_asm_valu_lit64.s

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,8 @@ v_ceil_f64 v[254:255], 0x3fc45f306dc9c882
235235
v_ceil_f64 v[254:255], 0.15915494309189532
236236
// GFX1250: v_ceil_f64_e32 v[254:255], 0.15915494309189532 ; encoding: [0xf8,0x30,0xfc,0x7f]
237237

238-
v_ceil_f64 v[254:255], INV2PI64
239-
// GFX1250: v_ceil_f64_e32 v[254:255], 0.15915494309189532 ; encoding: [0xf8,0x30,0xfc,0x7f]
240-
241-
// using INV2PI produces a different result
242238
v_ceil_f64 v[254:255], INV2PI
243-
// GFX1250: v_ceil_f64_e32 v[254:255], lit64(0x3fc45f306725feed) ; encoding: [0xfe,0x30,0xfc,0x7f,0xed,0xfe,0x25,0x67,0x30,0x5f,0xc4,0x3f]
239+
// GFX1250: v_ceil_f64_e32 v[254:255], 0.15915494309189532 ; encoding: [0xf8,0x30,0xfc,0x7f]
244240

245241
v_ceil_f64 v[254:255], -4.0
246242
// GFX1250: v_ceil_f64_e32 v[254:255], -4.0 ; encoding: [0xf7,0x30,0xfc,0x7f]

llvm/test/MC/AMDGPU/gfx7_err_pos.s

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ v_and_b32_e64 v0, INV2PI, v1
4242
// CHECK-NEXT:{{^}}v_and_b32_e64 v0, INV2PI, v1
4343
// CHECK-NEXT:{{^}} ^
4444

45-
v_and_b32_e64 v0, INV2PI64, v1
46-
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: literal operands are not supported
47-
// CHECK-NEXT:{{^}}v_and_b32_e64 v0, INV2PI64, v1
48-
// CHECK-NEXT:{{^}} ^
49-
5045
//==============================================================================
5146
// cache policy is not supported for SMRD instructions
5247

llvm/test/MC/AMDGPU/literals.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ v_trunc_f32 v0, lit(0.159154943091895317852646485335)
10301030

10311031
// SICI: v_trunc_f32_e32 v0, 0x3e22f983 ; encoding: [0xff,0x42,0x00,0x7e,0x83,0xf9,0x22,0x3e]
10321032
// GFX89: v_trunc_f32_e32 v0, 0.15915494 ; encoding: [0xf8,0x38,0x00,0x7e]
1033-
v_trunc_f32 v0, INV2PI64
1033+
v_trunc_f32 v0, INV2PI
10341034

10351035
//---------------------------------------------------------------------------//
10361036
// integer literal truncation checks

llvm/test/MC/AMDGPU/literalv216-err.s

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ v_pk_add_f16 v1, -0.15915494, v2
1616
v_pk_add_f16 v1, -INV2PI, v2
1717
// GFX9: :[[@LINE-1]]:{{[0-9]+}}: error: literal operands are not supported
1818

19-
v_pk_add_f16 v1, -INV2PI64, v2
20-
// GFX9: :[[@LINE-1]]:{{[0-9]+}}: error: literal operands are not supported
21-
2219
v_pk_add_f16 v1, -0.0, v2
2320
// GFX9: :[[@LINE-1]]:{{[0-9]+}}: error: literal operands are not supported
2421

0 commit comments

Comments
 (0)