Skip to content

Commit 3cdaf2c

Browse files
jayfoadpravinjagtap
authored andcommitted
[AMDGPU] Simplify use of hasMovrel and hasVGPRIndexMode (llvm#105680)
The generic subtarget has neither of these features. Rather than forcing HasMovrel on, it is simpler to expand dynamic vector indexing to a sequence of compare/select instructions. NFC for real subtargets. Change-Id: I0affa087067cb0e82f1d631d7a8f84551f2dbffe
1 parent 3948e72 commit 3cdaf2c

File tree

3 files changed

+1704
-11
lines changed

3 files changed

+1704
-11
lines changed

llvm/lib/Target/AMDGPU/GCNSubtarget.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,8 @@ GCNSubtarget &GCNSubtarget::initializeSubtargetDependencies(const Triple &TT,
143143
if (LDSBankCount == 0)
144144
LDSBankCount = 32;
145145

146-
if (TT.getArch() == Triple::amdgcn) {
147-
if (LocalMemorySize == 0)
148-
LocalMemorySize = 32768;
149-
150-
// Do something sensible for unspecified target.
151-
if (!HasMovrel && !HasVGPRIndexMode)
152-
HasMovrel = true;
153-
}
146+
if (TT.getArch() == Triple::amdgcn && LocalMemorySize == 0)
147+
LocalMemorySize = 32768;
154148

155149
AddressableLocalMemorySize = LocalMemorySize;
156150

@@ -366,7 +360,7 @@ bool GCNSubtarget::hasMadF16() const {
366360
}
367361

368362
bool GCNSubtarget::useVGPRIndexMode() const {
369-
return !hasMovrel() || (EnableVGPRIndexMode && hasVGPRIndexMode());
363+
return hasVGPRIndexMode() && (!hasMovrel() || EnableVGPRIndexMode);
370364
}
371365

372366
bool GCNSubtarget::useAA() const { return UseAA; }

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13613,12 +13613,15 @@ bool SITargetLowering::shouldExpandVectorDynExt(unsigned EltSize,
1361313613

1361413614
// On some architectures (GFX9) movrel is not available and it's better
1361513615
// to expand.
13616-
if (!Subtarget->hasMovrel())
13616+
if (Subtarget->useVGPRIndexMode())
1361713617
return NumInsts <= 16;
1361813618

1361913619
// If movrel is available, use it instead of expanding for vector of 8
1362013620
// elements.
13621-
return NumInsts <= 15;
13621+
if (Subtarget->hasMovrel())
13622+
return NumInsts <= 15;
13623+
13624+
return true;
1362213625
}
1362313626

1362413627
bool SITargetLowering::shouldExpandVectorDynExt(SDNode *N) const {

0 commit comments

Comments
 (0)