Author: Florian Hahn Date: 2021-01-25T19:38:08Z New Revision: 76afbf60ed7fb48233c9af9f74f2e8399fd38214
URL: https://github.com/llvm/llvm-project/commit/76afbf60ed7fb48233c9af9f74f2e8399fd38214 DIFF: https://github.com/llvm/llvm-project/commit/76afbf60ed7fb48233c9af9f74f2e8399fd38214.diff LOG: [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. Added: Modified: llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp Removed: ################################################################################ diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp index f5565c1e0feb..1a54603faf22 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<VPInstruction>(Ingredient); Instruction *Inst = cast<Instruction>(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(); } } _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits