[llvm] [VPlan] Model FOR resume value extraction in VPlan. (PR #93396)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 4 14:25:55 PDT 2024
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 c631131a1490af9f908a3a3be9aae5295ecff67d ac19de38509b88ce4259b7759e8be92b034fbbf6 -- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp llvm/lib/Transforms/Vectorize/VPlan.h llvm/lib/Transforms/Vectorize/VPlanTransforms.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 0a3d9e0be8..7cc0959a0a 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -56,10 +56,10 @@
#include "llvm/Transforms/Vectorize/LoopVectorize.h"
#include "LoopVectorizationPlanner.h"
#include "VPRecipeBuilder.h"
-#include "VPlanPatternMatch.h"
#include "VPlan.h"
#include "VPlanAnalysis.h"
#include "VPlanHCFGBuilder.h"
+#include "VPlanPatternMatch.h"
#include "VPlanTransforms.h"
#include "VPlanVerifier.h"
#include "llvm/ADT/APInt.h"
@@ -607,8 +607,8 @@ protected:
BasicBlock *MiddleBlock, BasicBlock *VectorHeader,
VPlan &Plan, VPTransformState &State);
- /// Create the phi node for the resume value of first order recurrences in the scalar preheader and
- /// update the users in the scalar loop.
+ /// Create the phi node for the resume value of first order recurrences in the
+ /// scalar preheader and update the users in the scalar loop.
void fixFixedOrderRecurrence(VPLiveOut *LO, VPTransformState &State);
/// Iteratively sink the scalarized operands of a predicated instruction into
@@ -3475,22 +3475,26 @@ void InnerLoopVectorizer::fixFixedOrderRecurrence(VPLiveOut *LO,
// Extract the last vector element in the middle block. This will be the
// initial value for the recurrence when jumping to the scalar loop.
VPValue *VPExtract = LO->getOperand(0);
-using namespace llvm::VPlanPatternMatch;
- assert(match(VPExtract, m_VPInstruction<VPInstruction::ExtractFromEnd>(m_VPValue(), m_VPValue())) && "FOR LiveOut expects to use an extract from end.");
+ using namespace llvm::VPlanPatternMatch;
+ assert(match(VPExtract, m_VPInstruction<VPInstruction::ExtractFromEnd>(
+ m_VPValue(), m_VPValue())) &&
+ "FOR LiveOut expects to use an extract from end.");
Value *ResumeScalarFOR = State.get(VPExtract, UF - 1, true);
// Fix the initial value of the original recurrence in the scalar loop.
Builder.SetInsertPoint(LoopScalarPreHeader, LoopScalarPreHeader->begin());
PHINode *ScalarHeaderPhi = LO->getPhi();
- auto *NewScalarHeaderPhi = Builder.CreatePHI(ScalarHeaderPhi->getType(), 2, "scalar.recur.init");
+ auto *NewScalarHeaderPhi =
+ Builder.CreatePHI(ScalarHeaderPhi->getType(), 2, "scalar.recur.init");
auto *InitScalarFOR =
ScalarHeaderPhi->getIncomingValueForBlock(LoopScalarPreHeader);
for (auto *BB : predecessors(LoopScalarPreHeader)) {
auto *Incoming = BB == LoopMiddleBlock ? ResumeScalarFOR : InitScalarFOR;
- NewScalarHeaderPhi ->addIncoming(Incoming, BB);
+ NewScalarHeaderPhi->addIncoming(Incoming, BB);
}
- ScalarHeaderPhi->setIncomingValueForBlock(LoopScalarPreHeader, NewScalarHeaderPhi );
+ ScalarHeaderPhi->setIncomingValueForBlock(LoopScalarPreHeader,
+ NewScalarHeaderPhi);
ScalarHeaderPhi->setName("scalar.recur");
}
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index b75ff6621e..943edc3520 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -3166,7 +3166,9 @@ class VPlan {
/// definitions are VPValues that hold a pointer to their underlying IR.
SmallVector<VPValue *, 16> VPLiveInsToFree;
- /// Values used outside the plan. It contains live-outs that need fixing. Any live-out that is fixed outside VPlan needs to be removed. The remaining live-outs are fixed via VPLiveOut::fixPhi.
+ /// Values used outside the plan. It contains live-outs that need fixing. Any
+ /// live-out that is fixed outside VPlan needs to be removed. The remaining
+ /// live-outs are fixed via VPLiveOut::fixPhi.
MapVector<PHINode *, VPLiveOut *> LiveOuts;
/// Mapping from SCEVs to the VPValues representing their expansions.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 7a80babc13..75e2352f97 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -887,7 +887,7 @@ bool VPlanTransforms::adjustFixedOrderRecurrences(VPlan &Plan,
//
// middle.block:
// s_penultimate = v2(2) = v3(3)
- // s_resume = v2(3)
+ // s_resume = v2(3)
// br cond, scalar.ph, exit.block
//
// scalar.ph:
@@ -903,13 +903,14 @@ bool VPlanTransforms::adjustFixedOrderRecurrences(VPlan &Plan,
//
// exit.block:
// lo = lcssa.phi [s1, scalar.body], [s.penultimate, middle.block]
- //
+ //
// After execution completes the vector loop, we extract the next value of
// the recurrence (x) to use as the initial value in the scalar loop. This
// is modeled by ExtractFromEnd.
Type *IntTy = Plan.getCanonicalIV()->getScalarType();
- // Extract the penultimate value of the recurrence and update VPLiveOut users of the recurrence splice.
+ // Extract the penultimate value of the recurrence and update VPLiveOut
+ // users of the recurrence splice.
auto *Penultimate = cast<VPInstruction>(MiddleBuilder.createNaryOp(
VPInstruction::ExtractFromEnd,
{FOR->getBackedgeValue(),
``````````
</details>
https://github.com/llvm/llvm-project/pull/93396
More information about the llvm-commits
mailing list