diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp index f5565c1e0feb49..1a54603faf22d3 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp @@ -35,7 +35,6 @@ void VPlanTransforms::VPInstructionsToVPRecipes( Plan->addCBV(NCondBit); } } - VPValue DummyValue; for (VPBlockBase *Base : RPOT) { // Do not widen instructions in pre-header and exit blocks. if (Base->getNumPredecessors() == 0 || Base->getNumSuccessors() == 0) @@ -49,6 +48,7 @@ void VPlanTransforms::VPInstructionsToVPRecipes( VPInstruction *VPInst = cast(Ingredient); Instruction *Inst = cast(VPInst->getUnderlyingValue()); if (DeadInstructions.count(Inst)) { + VPValue DummyValue; VPInst->replaceAllUsesWith(&DummyValue); Ingredient->eraseFromParent(); continue; @@ -80,7 +80,11 @@ void VPlanTransforms::VPInstructionsToVPRecipes( new VPWidenRecipe(*Inst, Plan->mapToVPValues(Inst->operands())); NewRecipe->insertBefore(Ingredient); - VPInst->replaceAllUsesWith(&DummyValue); + if (NewRecipe->getNumDefinedValues() == 1) + VPInst->replaceAllUsesWith(NewRecipe->getVPValue()); + else + assert(NewRecipe->getNumDefinedValues() == 0 && + "Only recpies with zero or one defined values expected"); Ingredient->eraseFromParent(); } }