[llvm] [SLP]Charge extract latency for extracts feeding memory addresses (PR #224634)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 21 09:51:55 PDT 2026
================
@@ -19757,6 +19761,27 @@ InstructionCost BoUpSLP::getTreeCost(InstructionCost TreeCost,
It->second = DT->findNearestCommonDominator(It->second, UseBlock);
}
+ // An extract feeds a memory address if any external user of the scalar is
+ // a GEP index or the pointer operand of a load/store. The extract is priced
+ // once per scalar, so all its uses are checked for order independence.
+ auto IsExtractOnAddressPath = [&](Value *Scalar) {
+ return any_of(ExternalUses, [&](const ExternalUser &EU) {
+ if (EU.Scalar != Scalar || EphValues.count(EU.User))
+ return false;
+ Value *Usr = LookThroughIndexCast(EU.User);
+ if (auto *GEP = dyn_cast_if_present<GetElementPtrInst>(Usr))
+ // Conservatively assume an address use if there are too many to check.
+ return GEP->hasNUsesOrMore(UsesLimit) ||
+ any_of(GEP->users(), [GEP](User *U) {
+ return match(U,
+ m_CombineOr(m_Load(m_Specific(GEP)),
+ m_Store(m_Value(), m_Specific(GEP))));
----------------
alexey-bataev wrote:
It is not a store-related, it is address-related, which feeds into mem operations
https://github.com/llvm/llvm-project/pull/224634
More information about the llvm-commits
mailing list