[llvm] [TTI] Consistently pass the pointer type to getAddressComputationCost. NFCI (PR #152657)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 11 01:14:05 PDT 2025


================
@@ -1675,13 +1675,14 @@ class TargetTransformInfo {
 
   /// \returns The cost of the address computation. For most targets this can be
   /// merged into the instruction indexing mode. Some targets might want to
-  /// distinguish between address computation for memory operations on vector
-  /// types and scalar types. Such targets should override this function.
-  /// The 'SE' parameter holds pointer for the scalar evolution object which
-  /// is used in order to get the Ptr step value in case of constant stride.
-  /// The 'Ptr' parameter holds SCEV of the access pointer.
-  LLVM_ABI InstructionCost getAddressComputationCost(
-      Type *Ty, ScalarEvolution *SE = nullptr, const SCEV *Ptr = nullptr) const;
+  /// distinguish between address computation for memory operations with vector
+  /// types and scalar pointer types. Such targets should override this
+  /// function. \p SE holds the pointer for the scalar evolution object which is
+  /// used in order to get the Ptr step value in case of constant stride. \p Ptr
+  /// holds the SCEV of the access pointer.
+  LLVM_ABI InstructionCost
+  getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE = nullptr,
----------------
david-arm wrote:

Or a single hook that takes an enum parameter providing more context? i.e.

```
getAddressComputationCost(Type *PtrTy, Value *Stride)
```

where you'd have Stride == ConstantInt(X) for contiguous loads (X==1) or strided loads (X > 1), or Stride == non-constant for non-constant strides, or Stride == nullptr indicates these are gathers/scatters. Given that most uses of the SCEV argument seem to relate to the stride, perhaps that allows you to kill off the SCEV argument entirely this way?

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


More information about the llvm-commits mailing list