[llvm] [AMDGPU] Implement LSR cost model for GFX9+ (PR #184138)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 6 06:16:43 PST 2026


================
@@ -1703,3 +1704,50 @@ GCNTTIImpl::getInstructionUniformity(const Value *V) const {
 
   return InstructionUniformity::Default;
 }
+
+InstructionCost GCNTTIImpl::getScalingFactorCost(Type *Ty, GlobalValue *BaseGV,
+                                                 StackOffset BaseOffset,
+                                                 bool HasBaseReg, int64_t Scale,
+                                                 unsigned AddrSpace) const {
+  if (HasBaseReg && Scale != 0) {
+    // gfx1250+ can fold base+scale*index into the instruction when scale
+    // equals the memory access size (scale_offset bit). Supported address
+    // spaces: flat, global, constant, private (scratch).
+    if (getST()->hasScaleOffset() && Ty && Ty->isSized() &&
+        (AddrSpace == AMDGPUAS::FLAT_ADDRESS ||
+         AddrSpace == AMDGPUAS::GLOBAL_ADDRESS ||
+         AddrSpace == AMDGPUAS::CONSTANT_ADDRESS ||
----------------
arsenm wrote:

Yes, it should be private, local + isExtendedGlobalAddrSpace

https://github.com/llvm/llvm-project/pull/184138


More information about the llvm-commits mailing list