[llvm] [X86] EltsFromConsecutiveLoads - handle trunc(wideload()) patterns (PR #199371)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 6 05:41:52 PDT 2026


================
@@ -8055,6 +8055,104 @@ 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) {
----------------
RKSimon wrote:

(style)
```suggestion
      for (unsigned K = 1; K < NumElems && AllMatch; ++K) {
```

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


More information about the llvm-commits mailing list