Skip to content

Commit 76afbf6

Browse files
committed
[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.
1 parent 4bb6244 commit 76afbf6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ void VPlanTransforms::VPInstructionsToVPRecipes(
3535
Plan->addCBV(NCondBit);
3636
}
3737
}
38-
VPValue DummyValue;
3938
for (VPBlockBase *Base : RPOT) {
4039
// Do not widen instructions in pre-header and exit blocks.
4140
if (Base->getNumPredecessors() == 0 || Base->getNumSuccessors() == 0)
@@ -49,6 +48,7 @@ void VPlanTransforms::VPInstructionsToVPRecipes(
4948
VPInstruction *VPInst = cast<VPInstruction>(Ingredient);
5049
Instruction *Inst = cast<Instruction>(VPInst->getUnderlyingValue());
5150
if (DeadInstructions.count(Inst)) {
51+
VPValue DummyValue;
5252
VPInst->replaceAllUsesWith(&DummyValue);
5353
Ingredient->eraseFromParent();
5454
continue;
@@ -80,7 +80,11 @@ void VPlanTransforms::VPInstructionsToVPRecipes(
8080
new VPWidenRecipe(*Inst, Plan->mapToVPValues(Inst->operands()));
8181

8282
NewRecipe->insertBefore(Ingredient);
83-
VPInst->replaceAllUsesWith(&DummyValue);
83+
if (NewRecipe->getNumDefinedValues() == 1)
84+
VPInst->replaceAllUsesWith(NewRecipe->getVPValue());
85+
else
86+
assert(NewRecipe->getNumDefinedValues() == 0 &&
87+
"Only recpies with zero or one defined values expected");
8488
Ingredient->eraseFromParent();
8589
}
8690
}

0 commit comments

Comments
 (0)