[PATCH] R600/SI: Consider adjacent offsets in getLdStBaseRegImmOfs
Matt Arsenault
Matthew.Arsenault at amd.com
Tue Jul 29 14:45:20 PDT 2014
We can treat ds_read2_* as a single offset if the offsets are adjacent.
No test since emission of read2 instructions for partially
aligned loads isn't implemented yet.
http://reviews.llvm.org/D4711
Files:
lib/Target/R600/SIInstrInfo.cpp
Index: lib/Target/R600/SIInstrInfo.cpp
===================================================================
--- lib/Target/R600/SIInstrInfo.cpp
+++ lib/Target/R600/SIInstrInfo.cpp
@@ -37,25 +37,43 @@
const TargetRegisterInfo *TRI) const {
unsigned Opc = LdSt->getOpcode();
if (isDS(Opc)) {
-
const MachineOperand *OffsetImm = getNamedOperand(*LdSt,
AMDGPU::OpName::offset);
-
- if (!OffsetImm) {
- // The 2 offset instructions use offset0 and offset1 instead. This
- // function only handles simple instructions with only a single offset, so
- // we ignore them.
-
- // TODO: Handle consecutive offsets as a single load.
- return false;
+ if (OffsetImm) {
+ // Normal, single offset LDS instruction.
+ const MachineOperand *AddrReg = getNamedOperand(*LdSt,
+ AMDGPU::OpName::addr);
+
+ BaseReg = AddrReg->getReg();
+ Offset = OffsetImm->getImm();
+ return true;
}
- const MachineOperand *AddrReg = getNamedOperand(*LdSt,
- AMDGPU::OpName::addr);
+ // The 2 offset instructions use offset0 and offset1 instead. We can treat
+ // these as a load with a single offset if the 2 offsets are consecutive. We
+ // will use this for some partially aligned loads.
+ const MachineOperand *Offset0Imm = getNamedOperand(*LdSt,
+ AMDGPU::OpName::offset0);
+ const MachineOperand *Offset1Imm = getNamedOperand(*LdSt,
+ AMDGPU::OpName::offset1);
+
+ uint8_t Offset0 = Offset0Imm->getImm();
+ uint8_t Offset1 = Offset1Imm->getImm();
+ assert(Offset1 > Offset0);
+
+ if (Offset1 - Offset0 == 1) {
+ // Each of these offsets is in element sized units, so we need to convert
+ // to bytes of the individual reads.
+ unsigned EltSize = getOpRegClass(*LdSt, 0)->getSize() / 2;
+
+ const MachineOperand *AddrReg = getNamedOperand(*LdSt,
+ AMDGPU::OpName::addr);
+ BaseReg = AddrReg->getReg();
+ Offset = EltSize * Offset0;
+ return true;
+ }
- BaseReg = AddrReg->getReg();
- Offset = OffsetImm->getImm();
- return true;
+ return false;
}
if (isMUBUF(Opc) || isMTBUF(Opc)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4711.11995.patch
Type: text/x-patch
Size: 2475 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140729/2e049eb1/attachment.bin>
More information about the llvm-commits
mailing list