Skip to content

Commit b02b5b7

Browse files
authored
[AMDGPU] Simplify use of hasMovrel and hasVGPRIndexMode (#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.
1 parent f53bfa3 commit b02b5b7

File tree

3 files changed

+1712
-11
lines changed

3 files changed

+1712
-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
@@ -13350,12 +13350,15 @@ bool SITargetLowering::shouldExpandVectorDynExt(unsigned EltSize,
1335013350

1335113351
// On some architectures (GFX9) movrel is not available and it's better
1335213352
// to expand.
13353-
if (!Subtarget->hasMovrel())
13353+
if (Subtarget->useVGPRIndexMode())
1335413354
return NumInsts <= 16;
1335513355

1335613356
// If movrel is available, use it instead of expanding for vector of 8
1335713357
// elements.
13358-
return NumInsts <= 15;
13358+
if (Subtarget->hasMovrel())
13359+
return NumInsts <= 15;
13360+
13361+
return true;
1335913362
}
1336013363

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

0 commit comments

Comments
 (0)