From 76afbf60ed7fb48233c9af9f74f2e8399fd38214 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Mon, 25 Jan 2021 19:34:59 +0000 Subject: [PATCH] [VPlan] Replace uses with new value in VPInstructionsToVPRecipe (NFC). Now that VPRecipeBase inherits from VPDef, we can always use the new VPValue for replacement, if the recipe defines one. Given the recipes that are supported at the moment, all new recipes must have either 0 or 1 defined values. --- llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp index f5565c1..1a54603 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(); } } -- 2.7.4