[llvm] [VPlan] Fix packed replication of struct types (PR #160274)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 25 01:19:24 PDT 2025


================
@@ -3267,11 +3267,23 @@ void VPPredInstPHIRecipe::execute(VPTransformState &State) {
   // also do that packing, thereby "hoisting" the insert-element sequence.
   // Otherwise, a phi node for the scalar value is needed.
   if (State.hasVectorValue(getOperand(0))) {
-    Value *VectorValue = State.get(getOperand(0));
-    InsertElementInst *IEI = cast<InsertElementInst>(VectorValue);
-    PHINode *VPhi = State.Builder.CreatePHI(IEI->getType(), 2);
-    VPhi->addIncoming(IEI->getOperand(0), PredicatingBB); // Unmodified vector.
-    VPhi->addIncoming(IEI, PredicatedBB); // New vector with inserted element.
+    auto *VecI = cast<Instruction>(State.get(getOperand(0)));
+    assert(isa<InsertElementInst>(VecI) ||
+           isa<InsertValueInst>(VecI) &&
----------------
lukel97 wrote:

I tried this originally but there's something about it being in an assert macro that causes an error. It's not able to see the parameter pack isa overload for some reason 

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


More information about the llvm-commits mailing list