return new VPBlendRecipe(Phi, Masks);
}
-bool VPRecipeBuilder::tryToWiden(Instruction *I, VPBasicBlock *VPBB,
- VFRange &Range) {
+VPWidenRecipe *VPRecipeBuilder::tryToWiden(Instruction *I, VFRange &Range) {
bool IsPredicated = LoopVectorizationPlanner::getDecisionAndClampRange(
[&](unsigned VF) { return CM.isScalarWithPredication(I, VF); }, Range);
if (IsPredicated)
- return false;
+ return nullptr;
auto IsVectorizableOpcode = [](unsigned Opcode) {
switch (Opcode) {
};
if (!IsVectorizableOpcode(I->getOpcode()))
- return false;
+ return nullptr;
if (CallInst *CI = dyn_cast<CallInst>(I)) {
Intrinsic::ID ID = getVectorIntrinsicIDForCall(CI, TLI);
if (ID && (ID == Intrinsic::assume || ID == Intrinsic::lifetime_end ||
ID == Intrinsic::lifetime_start || ID == Intrinsic::sideeffect))
- return false;
+ return nullptr;
}
auto willWiden = [&](unsigned VF) -> bool {
};
if (!LoopVectorizationPlanner::getDecisionAndClampRange(willWiden, Range))
- return false;
+ return nullptr;
// Success: widen this instruction.
- VPWidenRecipe *WidenRecipe = new VPWidenRecipe(*I);
- setRecipe(I, WidenRecipe);
- VPBB->appendRecipe(WidenRecipe);
- return true;
+ return new VPWidenRecipe(*I);
}
VPBasicBlock *VPRecipeBuilder::handleReplication(
// Check if Instr is to be widened by a general VPWidenRecipe, after
// having first checked for specific widening recipes.
- if (tryToWiden(Instr, VPBB, Range))
+ if ((Recipe = tryToWiden(Instr, Range))) {
+ setRecipe(Instr, Recipe);
+ VPBB->appendRecipe(Recipe);
return true;
+ }
return false;
}
VPBlendRecipe *tryToBlend(Instruction *I, VPlanPtr &Plan);
/// Check if \p I can be widened within the given VF \p Range. If \p I can be
- /// widened for \p Range.Start, check if the last recipe of \p VPBB can be
- /// extended to include \p I or else build a new VPWidenRecipe for it and
- /// append it to \p VPBB. Return true if \p I can be widened for Range.Start,
- /// false otherwise. Range.End may be decreased to ensure same decision from
- /// \p Range.Start to \p Range.End.
- bool tryToWiden(Instruction *I, VPBasicBlock *VPBB, VFRange &Range);
+ /// widened for \p Range.Start, build a new VPWidenRecipe and return it.
+ /// Range.End may be decreased to ensure same decision from \p Range.Start to
+ /// \p Range.End.
+ VPWidenRecipe *tryToWiden(Instruction *I, VFRange &Range);
/// Create a replicating region for instruction \p I that requires
/// predication. \p PredRecipe is a VPReplicateRecipe holding \p I.