Skip to content

Commit

Permalink
AMDGPU: Always use VGPR indexing on GFX9
Browse files Browse the repository at this point in the history
Reviewers: arsenm

Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, tony-tye, dstuttard, tpr

Differential Revision: https://reviews.llvm.org/D31157

llvm-svn: 298396
  • Loading branch information
Marek Olsak committed Mar 21, 2017
1 parent 5e7f06f commit e22fdb9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPU.td
Expand Up @@ -406,7 +406,7 @@ def FeatureGFX9 : SubtargetFeatureGeneration<"GFX9",
FeatureWavefrontSize64, FeatureFlatAddressSpace, FeatureGCN,
FeatureGCN3Encoding, FeatureCIInsts, Feature16BitInsts,
FeatureSMemRealTime, FeatureScalarStores, FeatureInv2PiInlineImm,
FeatureApertureRegs, FeatureGFX9Insts, FeatureVOP3P
FeatureApertureRegs, FeatureGFX9Insts, FeatureVOP3P, FeatureVGPRIndexMode
]
>;

Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h
Expand Up @@ -625,6 +625,10 @@ class SISubtarget final : public AMDGPUSubtarget {
return HasVGPRIndexMode;
}

bool useVGPRIndexMode(bool UserEnable) const {
return !hasMovrel() || (UserEnable && hasVGPRIndexMode());
}

bool hasScalarCompareEq64() const {
return getGeneration() >= VOLCANIC_ISLANDS;
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/AMDGPU/SIISelLowering.cpp
Expand Up @@ -1667,7 +1667,7 @@ static MachineBasicBlock *emitIndirectSrc(MachineInstr &MI,
std::tie(SubReg, Offset)
= computeIndirectRegAndOffset(TRI, VecRC, SrcReg, Offset);

bool UseGPRIdxMode = ST.hasVGPRIndexMode() && EnableVGPRIndexMode;
bool UseGPRIdxMode = ST.useVGPRIndexMode(EnableVGPRIndexMode);

if (setM0ToIndexFromSGPR(TII, MRI, MI, Offset, UseGPRIdxMode, true)) {
MachineBasicBlock::iterator I(&MI);
Expand Down Expand Up @@ -1769,7 +1769,7 @@ static MachineBasicBlock *emitIndirectDst(MachineInstr &MI,
std::tie(SubReg, Offset) = computeIndirectRegAndOffset(TRI, VecRC,
SrcVec->getReg(),
Offset);
bool UseGPRIdxMode = ST.hasVGPRIndexMode() && EnableVGPRIndexMode;
bool UseGPRIdxMode = ST.useVGPRIndexMode(EnableVGPRIndexMode);

if (Idx->getReg() == AMDGPU::NoRegister) {
MachineBasicBlock::iterator I(&MI);
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/AMDGPU/indirect-addressing-si.ll
@@ -1,6 +1,7 @@
; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=MOVREL %s
; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=MOVREL %s
; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -amdgpu-vgpr-index-mode -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=IDXMODE %s
; RUN: llc -march=amdgcn -mcpu=gfx900 -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=IDXMODE %s

; Tests for indirect addressing on SI, which is implemented using dynamic
; indexing of vectors.
Expand Down

0 comments on commit e22fdb9

Please sign in to comment.