[llvm] [X86] EltsFromConsecutiveLoads - handle trunc(wideload()) patterns (PR #199371)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 9 03:04:27 PDT 2026
================
@@ -8055,6 +8055,102 @@ static SDValue EltsFromConsecutiveLoads(EVT VT, ArrayRef<SDValue> Elts,
}
}
+ // STRIDED - element loads at a uniform byte stride larger than the element
+ // size are folded into wide load(s) + vector truncation.
+ // Depth 1 lets the REVERSE block below recurse into us to catch reverse
+ // strides.
+ if (Depth <= 1 && Subtarget.hasAVX2() && !IsConsecutiveLoad &&
+ LoadMask.isAllOnes() && isPowerOf2_32(NumElems) && BaseSizeInBits <= 32 &&
+ VT.getSizeInBits() >= 128) {
+ unsigned WideEltBits = 0;
+ for (unsigned Trial : {16u, 32u, 64u}) {
+ if (Trial <= BaseSizeInBits || Trial % BaseSizeInBits != 0)
+ continue;
+ unsigned LaneStride = Trial / BaseSizeInBits;
+ bool AllMatch = true;
+ for (unsigned K = 1; K < NumElems && AllMatch; ++K) {
+ AllMatch = ByteOffsets[K] == 0 &&
----------------
RKSimon wrote:
although not necessary for the control flow, its slightly better to grok if we do:
```
AllMatch = AllMatch && ByteOffsets[K] == 0 &&
```
https://github.com/llvm/llvm-project/pull/199371
More information about the llvm-commits
mailing list