Skip to content

[AMDGPU] Allow unaligned VGPR for ds_read_b96_tr_b6 #125169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4853,7 +4853,10 @@ bool AMDGPUAsmParser::validateAGPRLdSt(const MCInst &Inst) const {

bool AMDGPUAsmParser::validateVGPRAlign(const MCInst &Inst) const {
auto FB = getFeatureBits();
if (!FB[AMDGPU::FeatureGFX90AInsts])
unsigned Opc = Inst.getOpcode();
// DS_READ_B96_TR_B6 is the only DS instruction in GFX950, that allows
// unaligned VGPR. All others only allow even aligned VGPRs.
if (!(FB[AMDGPU::FeatureGFX90AInsts]) || Opc == AMDGPU::DS_READ_B96_TR_B6_vi)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra parentheses. Also we probably should not directly special case the opcode here. This should come from the register class constraint of the operand

return true;

const MCRegisterInfo *MRI = getMRI();
Expand Down
4 changes: 0 additions & 4 deletions llvm/test/MC/AMDGPU/gfx950-unsupported.s
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,6 @@ ds_read_b64_tr_b16 v[2:3], v2 offset:-64
//===----------------------------------------------------------------------===//
// ds_read_b96_tr_b6
//===----------------------------------------------------------------------===//
ds_read_b96_tr_b6 v[1:3], v0
// ERR: :[[@LINE-1]]:{{[0-9]+}}: error: invalid register class: vgpr tuples must be 64 bit aligned
// W32-ERR: :[[@LINE-2]]:{{[0-9]+}}: error: instruction not supported on this GPU

ds_read_b96_tr_b6 v1, v0
// ERR: :[[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
// W32-ERR: :[[@LINE-2]]:{{[0-9]+}}: error: instruction not supported on this GPU
Expand Down
8 changes: 8 additions & 0 deletions llvm/test/MC/AMDGPU/gfx950_asm_read_tr.s
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ ds_read_b96_tr_b6 v[0:2], v0
ds_read_b96_tr_b6 v[2:4], v2 offset:64
// GFX940-ERR: [[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
// GFX950: encoding: [0x40,0x00,0xc2,0xd9,0x02,0x00,0x00,0x02]

ds_read_b96_tr_b6 v[1:3], v0
// GFX940-ERR: [[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
// GFX950: encoding: [0x00,0x00,0xc2,0xd9,0x00,0x00,0x00,0x01]

ds_read_b96_tr_b6 v[1:3], v2 offset:64
// GFX940-ERR: [[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
// GFX950: encoding: [0x40,0x00,0xc2,0xd9,0x02,0x00,0x00,0x01]
6 changes: 6 additions & 0 deletions llvm/test/MC/Disassembler/AMDGPU/gfx950_dasm_ds_read_tr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,9 @@

# GFX950: ds_read_b96_tr_b6 v[2:4], v2 offset:64 ; encoding: [0x40,0x00,0xc2,0xd9,0x02,0x00,0x00,0x02]
0x40,0x00,0xc2,0xd9,0x02,0x00,0x00,0x02

# GFX950: ds_read_b96_tr_b6 v[1:3], v0 ; encoding: [0x00,0x00,0xc2,0xd9,0x00,0x00,0x00,0x01]
0x00,0x00,0xc2,0xd9,0x00,0x00,0x00,0x01

# GFX950: ds_read_b96_tr_b6 v[1:3], v2 offset:64 ; encoding: [0x40,0x00,0xc2,0xd9,0x02,0x00,0x00,0x01]
0x40,0x00,0xc2,0xd9,0x02,0x00,0x00,0x01