[llvm] [VectorCombine] Combine adjacent loads feeding as shuffle operands (PR #213007)

Hari Limaye via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 24 06:32:50 PDT 2026


================
@@ -6374,6 +6378,210 @@ bool VectorCombine::shrinkLoadForShuffles(Instruction &I) {
   return false;
 }
 
+// Attempt to combine two adjacent fixed-length vector loads, that only feed
+// shufflevector instructions, into a single wider load, rewriting every such
+// shuffle so that operand 0 is the wide load and operand 1 is poison.
+// clang-format off
+// e.g.
+//   %loadA = load <16 x i8>, ptr %a
+//   %gep = getelementptr inbounds <16 x i8>, ptr %a, i64 1
+//   %loadB = load <16 x i8>, ptr %gep
+//   %shuffle0 = shufflevector <16 x i8> %loadA, <16 x i8> %loadB,
+//               <32 x i8> <...>
+//   %shuffle1 = shufflevector <16 x i8> %loadA, <16 x i8> %loadB,
+//               <32 x i8> <...>
+//
+// The fold would transform this to:
+//   %loadAB = load <32 x i8>, ptr %a
+//   %shuffle0 = shufflevector <32 x i8> %loadAB, <32 x i8> poison, 
----------------
hazzlim wrote:

Nit: trailing whitespace
```suggestion
//   %shuffle0 = shufflevector <32 x i8> %loadAB, <32 x i8> poison,
```

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


More information about the llvm-commits mailing list