-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[VPlan] Transform VPFirstOrderRecurrencePHIRecipe into concrete recipes #172009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3667,7 +3667,7 @@ void VPlanTransforms::dissolveLoopRegions(VPlan &Plan) { | |
| R->dissolveToCFGLoop(); | ||
| } | ||
|
|
||
| void VPlanTransforms::convertToConcreteRecipes(VPlan &Plan) { | ||
| void VPlanTransforms::convertToConcreteRecipes(VPlan &Plan, ElementCount VF) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use the plans symbolic VF (getVF()) / hasScalarVFOnly instead of having to pass the VF here? |
||
| VPTypeAnalysis TypeInfo(Plan); | ||
| SmallVector<VPRecipeBase *> ToRemove; | ||
| for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>( | ||
|
|
@@ -3695,6 +3695,34 @@ void VPlanTransforms::convertToConcreteRecipes(VPlan &Plan) { | |
| continue; | ||
| } | ||
|
|
||
| if (auto *FORPhiR = dyn_cast<VPFirstOrderRecurrencePHIRecipe>(&R)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be good to document the expansion here briefly |
||
| VPValue *InitVec = FORPhiR->getStartValue(); | ||
| DebugLoc DL = FORPhiR->getDebugLoc(); | ||
| if (VF.isVector()) { | ||
| VPBuilder PHBuilder(Plan.getVectorPreheader()); | ||
| VPValue *Poison = Plan.getOrAddLiveIn( | ||
| PoisonValue::get(TypeInfo.inferScalarType(InitVec))); | ||
| Type *IdxTy = Type::getInt32Ty(Plan.getContext()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, insertelement must take i32 type, so this hard-coding is the right thing to do? |
||
| VPValue *RuntimeVF = PHBuilder.createScalarZExtOrTrunc( | ||
| &Plan.getVF(), IdxTy, TypeInfo.inferScalarType(&Plan.getVF()), | ||
| DL); | ||
| VPValue *LastIdx = PHBuilder.createOverflowingOp( | ||
| Instruction::Sub, {RuntimeVF, Plan.getConstantInt(IdxTy, 1)}, | ||
| {false, false}, DL); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, should this set nsw?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can set nuw too. Maybe better to do that in a separate PR though just in case. |
||
| InitVec = PHBuilder.createNaryOp(Instruction::InsertElement, | ||
| {Poison, InitVec, LastIdx}, DL, | ||
| "vector.recur.init"); | ||
| } | ||
| auto *WidenPhi = | ||
| new VPWidenPHIRecipe(cast<PHINode>(FORPhiR->getUnderlyingInstr()), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be good to introduce VPFirstOrderRecurrencePHIRecipe::getPHINode() like in VPWidenInductionRecipe::getPHINode()? |
||
| InitVec, DL, "vector.recur"); | ||
| WidenPhi->addOperand(FORPhiR->getBackedgeValue()); | ||
| WidenPhi->insertBefore(FORPhiR); | ||
| FORPhiR->replaceAllUsesWith(WidenPhi); | ||
| ToRemove.push_back(FORPhiR); | ||
| continue; | ||
| } | ||
|
|
||
| // Expand VPBlendRecipe into VPInstruction::Select. | ||
| VPBuilder Builder(&R); | ||
| if (auto *Blend = dyn_cast<VPBlendRecipe>(&R)) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could move this directly after ExtractElement?