[llvm] [VPlan] Introduce ComputeReductionResult VPInstruction opcode. (PR #70253)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 28 06:00:25 PST 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 394bba766ddd2f5ea8ac8007dcadb724f79bafc4 3e6834b769e39edac04041b229cbddac292bc27e -- llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h llvm/lib/Transforms/Vectorize/LoopVectorize.cpp llvm/lib/Transforms/Vectorize/VPlan.cpp llvm/lib/Transforms/Vectorize/VPlan.h llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 0e4faa85fe..d80914c640 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7613,60 +7613,62 @@ LoopVectorizationPlanner::executePlan(
// Find the merge phi, which must be located in the preheader of the
// original scalar loop.
- return {&PhiR->getRecurrenceDescriptor(), *find_if(FinalValue->users(), [&](User *U){ return isa<PHINode>(U) && OrigScalarPH == P->getParent(); }));
- };
- for (VPRecipeBase &R : *cast<VPBasicBlock>(
- BestVPlan.getVectorLoopRegion()->getSingleSuccessor())) {
- const auto &[RedRdx, MergePhi] =
- GetMergePhiForReduction(dyn_cast<VPInstruction>(&R));
- if (!RedRdx)
- continue;
- ReductionResumeValues[RedRdx] = MergePhi;
- }
- // Keep all loop hints from the original loop on the vector loop (we'll
- // replace the vectorizer-specific hints below).
- MDNode *OrigLoopID = OrigLoop->getLoopID();
-
- std::optional<MDNode *> VectorizedLoopID =
- makeFollowupLoopID(OrigLoopID, {LLVMLoopVectorizeFollowupAll,
- LLVMLoopVectorizeFollowupVectorized});
-
- VPBasicBlock *HeaderVPBB =
- BestVPlan.getVectorLoopRegion()->getEntryBasicBlock();
- Loop *L = LI->getLoopFor(State.CFG.VPBB2IRBB[HeaderVPBB]);
- if (VectorizedLoopID)
- L->setLoopID(*VectorizedLoopID);
- else {
+ return {&PhiR->getRecurrenceDescriptor(), *find_if(FinalValue->users(), [&](User *U){
+ return isa<PHINode>(U) && OrigScalarPH == P->getParent(); }));
+ };
+ for (VPRecipeBase &R : *cast<VPBasicBlock>(
+ BestVPlan.getVectorLoopRegion()->getSingleSuccessor())) {
+ const auto &[RedRdx, MergePhi] =
+ GetMergePhiForReduction(dyn_cast<VPInstruction>(&R));
+ if (!RedRdx)
+ continue;
+ ReductionResumeValues[RedRdx] = MergePhi;
+ }
// Keep all loop hints from the original loop on the vector loop (we'll
// replace the vectorizer-specific hints below).
- if (MDNode *LID = OrigLoop->getLoopID())
- L->setLoopID(LID);
+ MDNode *OrigLoopID = OrigLoop->getLoopID();
- LoopVectorizeHints Hints(L, true, *ORE);
- Hints.setAlreadyVectorized();
- }
- TargetTransformInfo::UnrollingPreferences UP;
- TTI.getUnrollingPreferences(L, *PSE.getSE(), UP, ORE);
- if (!UP.UnrollVectorizedLoop || CanonicalIVStartValue)
- AddRuntimeUnrollDisableMetaData(L);
+ std::optional<MDNode *> VectorizedLoopID =
+ makeFollowupLoopID(OrigLoopID, {LLVMLoopVectorizeFollowupAll,
+ LLVMLoopVectorizeFollowupVectorized});
- // 3. Fix the vectorized code: take care of header phi's, live-outs,
- // predication, updating analyses.
- ILV.fixVectorizedLoop(State, BestVPlan);
+ VPBasicBlock *HeaderVPBB =
+ BestVPlan.getVectorLoopRegion()->getEntryBasicBlock();
+ Loop *L = LI->getLoopFor(State.CFG.VPBB2IRBB[HeaderVPBB]);
+ if (VectorizedLoopID)
+ L->setLoopID(*VectorizedLoopID);
+ else {
+ // Keep all loop hints from the original loop on the vector loop (we'll
+ // replace the vectorizer-specific hints below).
+ if (MDNode *LID = OrigLoop->getLoopID())
+ L->setLoopID(LID);
- ILV.printDebugTracesAtEnd();
+ LoopVectorizeHints Hints(L, true, *ORE);
+ Hints.setAlreadyVectorized();
+ }
+ TargetTransformInfo::UnrollingPreferences UP;
+ TTI.getUnrollingPreferences(L, *PSE.getSE(), UP, ORE);
+ if (!UP.UnrollVectorizedLoop || CanonicalIVStartValue)
+ AddRuntimeUnrollDisableMetaData(L);
- return {State.ExpandedSCEVs, ReductionResumeValues};
-}
+ // 3. Fix the vectorized code: take care of header phi's, live-outs,
+ // predication, updating analyses.
+ ILV.fixVectorizedLoop(State, BestVPlan);
+
+ ILV.printDebugTracesAtEnd();
+
+ return {State.ExpandedSCEVs, ReductionResumeValues};
+ }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
-void LoopVectorizationPlanner::printPlans(raw_ostream &O) {
+ void
+ LoopVectorizationPlanner::printPlans(raw_ostream & O) {
for (const auto &Plan : VPlans)
if (PrintVPlansInDotFormat)
Plan->printDOT(O);
else
Plan->print(O);
-}
+ }
#endif
//===--------------------------------------------------------------------===//
``````````
</details>
https://github.com/llvm/llvm-project/pull/70253
More information about the llvm-commits
mailing list