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

via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 3 04:54:44 PST 2026


================
@@ -1703,3 +1704,44 @@ 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 {
+  // AMDGPU has limited addressing modes. base+scale*index requires an extra
+  // ADD instruction, unlike architectures with rich addressing modes.
+  if (HasBaseReg && Scale != 0)
----------------
michaelselehov wrote:

Implemented `getScalingFactorCost` for scale_offset, but for LSR to actually consider scaled formulas, we'll also need to update `SITargetLowering::isLegalFlatAddressingMode` which currently rejects `Scale != 0` for all targets. I think that should be a separate PR.

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


More information about the llvm-commits mailing list