[llvm] [VPlan] Narrow interleave groups with distinct live-in operands. (PR #203778)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 14 14:24:22 PDT 2026
================
@@ -5661,15 +5667,33 @@ static bool isAlreadyNarrow(VPValue *VPV) {
// Convert the wide recipes defining the VPValues in \p Members feeding an
// interleave group to a single narrow variant. The first member is reused as
-// the narrowed recipe.
-static VPValue *
-narrowInterleaveGroupOp(ArrayRef<VPValue *> Members,
- SmallPtrSetImpl<VPValue *> &NarrowedOps) {
+// the narrowed recipe. Newly created loop-invariant recipes (e.g. a BuildVector
+// for distinct live-ins) are inserted into \p Preheader.
+static VPValue *narrowInterleaveGroupOp(ArrayRef<VPValue *> Members,
+ SmallPtrSetImpl<VPValue *> &NarrowedOps,
+ VPBasicBlock *Preheader) {
VPValue *V = Members.front();
auto *R = V->getDefiningRecipe();
- if (!R || NarrowedOps.contains(V))
+ if (NarrowedOps.contains(V))
return V;
+ if (!R) {
+ // V is a live-in. If all members are the same live-in, reuse it directly.
+ if (all_of(Members, equal_to(V)))
+ return V;
----------------
artagnon wrote:
Hm, do we need this? Will BuildVector with all-eq operands not fold to BCast due to simplifyRecipe, which will then be eliminated because only-first-lane-used, again due to simplifyRecipe I think?
https://github.com/llvm/llvm-project/pull/203778
More information about the llvm-commits
mailing list