[llvm] [SLPVectorizer] Handle InsertValueInst in getVectorElementSize (PR #215473)
Aditya Chaudhary via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 10 23:32:05 PDT 2026
https://github.com/aditya-chaudhary1 created https://github.com/llvm/llvm-project/pull/215473
When given an `InsertValueInst`, the `getVectorElementSize()` function was falling back to measuring the bit width of the instruction's result type (the aggregate type, e.g. { i64, i64 } -> 128 bits) instead of inspecting the scalar element value being inserted (operand(1) -> 64 bits).
This leads to an overestimated element bit-width, which restricts the calculated maximum vectorization factor and can prevent valid SLP vectorization of chains of insertvalue instructions.
>From 3ffb268cada1b63cf4fb7f6e2bde8b2999dcd0c8 Mon Sep 17 00:00:00 2001
From: Aditya-Chaudhary1 <aditya.chaudhary1 at ibm.com>
Date: Tue, 11 Aug 2026 02:29:30 -0400
Subject: [PATCH] handle invertValue instruction in getVectorElementSize
---
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index a04877d183516..331aebd4869da 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -27353,6 +27353,9 @@ unsigned BoUpSLP::getVectorElementSize(Value *V) {
if (auto *IEI = dyn_cast<InsertElementInst>(V))
return getVectorElementSize(IEI->getOperand(1));
+ if (auto *IVI = dyn_cast<InsertValueInst>(V))
+ return getVectorElementSize(IVI->getOperand(1));
+
auto E = InstrElementSize.find(V);
if (E != InstrElementSize.end())
return E->second;
More information about the llvm-commits
mailing list