summaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp')
-rw-r--r--llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp61
1 files changed, 4 insertions, 57 deletions
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 7fe40c3e0490..6c32bd1c64c8 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -805,8 +805,8 @@ static VPValue *optimizeEarlyExitInductionUser(VPlan &Plan,
VPValue *Op,
ScalarEvolution &SE) {
VPValue *Incoming, *Mask;
- if (!match(Op, m_ExtractLane(m_FirstActiveLane(m_VPValue(Mask)),
- m_VPValue(Incoming))))
+ if (!match(Op, m_VPInstruction<VPInstruction::ExtractLane>(
+ m_FirstActiveLane(m_VPValue(Mask)), m_VPValue(Incoming))))
return nullptr;
auto *WideIV = getOptimizableIVOf(Incoming, SE);
@@ -1274,7 +1274,8 @@ static void simplifyRecipe(VPSingleDefRecipe *Def, VPTypeAnalysis &TypeInfo) {
}
// Look through ExtractPenultimateElement (BuildVector ....).
- if (match(Def, m_ExtractPenultimateElement(m_BuildVector()))) {
+ if (match(Def, m_VPInstruction<VPInstruction::ExtractPenultimateElement>(
+ m_BuildVector()))) {
auto *BuildVector = cast<VPInstruction>(Def->getOperand(0));
Def->replaceAllUsesWith(
BuildVector->getOperand(BuildVector->getNumOperands() - 2));
@@ -2085,32 +2086,6 @@ bool VPlanTransforms::adjustFixedOrderRecurrences(VPlan &Plan,
// Set the first operand of RecurSplice to FOR again, after replacing
// all users.
RecurSplice->setOperand(0, FOR);
-
- // Check for users extracting at the penultimate active lane of the FOR.
- // If only a single lane is active in the current iteration, we need to
- // select the last element from the previous iteration (from the FOR phi
- // directly).
- for (VPUser *U : RecurSplice->users()) {
- if (!match(U, m_ExtractLane(m_LastActiveLane(m_VPValue()),
- m_Specific(RecurSplice))))
- continue;
-
- VPBuilder B(cast<VPInstruction>(U));
- VPValue *LastActiveLane = cast<VPInstruction>(U)->getOperand(0);
- Type *I64Ty = Type::getInt64Ty(Plan.getContext());
- VPValue *Zero = Plan.getOrAddLiveIn(ConstantInt::get(I64Ty, 0));
- VPValue *One = Plan.getOrAddLiveIn(ConstantInt::get(I64Ty, 1));
- VPValue *PenultimateIndex =
- B.createNaryOp(Instruction::Sub, {LastActiveLane, One});
- VPValue *PenultimateLastIter =
- B.createNaryOp(VPInstruction::ExtractLane,
- {PenultimateIndex, FOR->getBackedgeValue()});
- VPValue *LastPrevIter =
- B.createNaryOp(VPInstruction::ExtractLastElement, FOR);
- VPValue *Cmp = B.createICmp(CmpInst::ICMP_EQ, LastActiveLane, Zero);
- VPValue *Sel = B.createSelect(Cmp, LastPrevIter, PenultimateLastIter);
- cast<VPInstruction>(U)->replaceAllUsesWith(Sel);
- }
}
return true;
}
@@ -3500,34 +3475,6 @@ void VPlanTransforms::convertToConcreteRecipes(VPlan &Plan) {
ToRemove.push_back(Expr);
}
- // Expand LastActiveLane into Not + FirstActiveLane + Sub.
- auto *LastActiveL = dyn_cast<VPInstruction>(&R);
- if (LastActiveL &&
- LastActiveL->getOpcode() == VPInstruction::LastActiveLane) {
- // Create Not(Mask) for all operands.
- SmallVector<VPValue *, 2> NotMasks;
- for (VPValue *Op : LastActiveL->operands()) {
- VPValue *NotMask = Builder.createNot(Op, LastActiveL->getDebugLoc());
- NotMasks.push_back(NotMask);
- }
-
- // Create FirstActiveLane on the inverted masks.
- VPValue *FirstInactiveLane = Builder.createNaryOp(
- VPInstruction::FirstActiveLane, NotMasks,
- LastActiveL->getDebugLoc(), "first.inactive.lane");
-
- // Subtract 1 to get the last active lane.
- VPValue *One = Plan.getOrAddLiveIn(
- ConstantInt::get(Type::getInt64Ty(Plan.getContext()), 1));
- VPValue *LastLane = Builder.createNaryOp(
- Instruction::Sub, {FirstInactiveLane, One},
- LastActiveL->getDebugLoc(), "last.active.lane");
-
- LastActiveL->replaceAllUsesWith(LastLane);
- ToRemove.push_back(LastActiveL);
- continue;
- }
-
VPValue *VectorStep;
VPValue *ScalarStep;
if (!match(&R, m_VPInstruction<VPInstruction::WideIVStep>(