This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Fix ds_read2/write2 with unaligned offsets
ClosedPublic

Authored by foad on Nov 2 2020, 6:04 AM.

Details

Summary

These instructions use a scaled offset. We were wrongly selecting them
even when the required offset was not a multiple of the scale factor.

Diff Detail

Event Timeline

foad created this revision.Nov 2 2020, 6:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 2 2020, 6:04 AM
foad requested review of this revision.Nov 2 2020, 6:04 AM
arsenm added a comment.Nov 2 2020, 9:30 AM

Does the GlobalISel pattern have the same problem?

llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
1277–1278

I think the variable name align here is misleading since this isn't the memory alignment

1284–1286

split this into a isDSOffset2Legal function?

foad updated this revision to Diff 302567.Nov 3 2020, 6:40 AM

Use new isDSOffset2Legal, do the same for globalisel, and fix a globalisel bug with large offsets.

foad marked 2 inline comments as done.Nov 3 2020, 6:43 AM

Does the GlobalISel pattern have the same problem?

No, it had a different one :) For read2/write2_b64 it was passing 16 in as the last argument to isDSOffsetLegal, which is the bit width of the "offset" fields in the instruction. I think it's all good now.

llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
1277–1278

I used Size for the size in bytes of each of the 2 accesses.

arsenm accepted this revision.Nov 3 2020, 6:46 AM
This revision is now accepted and ready to land.Nov 3 2020, 6:46 AM
This revision was landed with ongoing or failed builds.Nov 3 2020, 7:16 AM
This revision was automatically updated to reflect the committed changes.
foad marked an inline comment as done.