[llvm] [SLP] Account for GEP pointer-chain cost when root scalars feed load/store indices (PR #192726)
Ryan Buchner via llvm-commits
llvm-commits at lists.llvm.org
Tue May 5 13:54:32 PDT 2026
================
@@ -19278,6 +19301,41 @@ InstructionCost BoUpSLP::getTreeCost(InstructionCost TreeCost,
ExtractCost += ExtraCost;
}
+ // Charge the pointer-chain cost difference once for the root entry when
+ // every external use of its scalars is a GEP feeding a single load/store
+ // (see the detection loop above). Vectorizing the root in this pattern
+ // forces lane extracts (or a vector GEP with unknown stride) to drive the
+ // address computation, which is typically more expensive than keeping the
+ // indices scalar in a unit-stride address chain. Add the delta once rather
----------------
bababuck wrote:
So
```
%t5 = extractelement <2 x i8> %t2, i32 1
%ptr = getelementptr inbounds i8, ptr %ptr, i32 %t5
```
is more expensive (ignoring the cost of the extract since that is accounted for elsewshere) than
```
%ptr = getelementptr inbounds i8, ptr %ptr, i32 %t2
```
https://github.com/llvm/llvm-project/pull/192726
More information about the llvm-commits
mailing list