-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[VPlan] Expand VPWidenIntOrFpInductionRecipe into separate recipes #118638
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
Changes from 18 commits
e72140a
6fc4a7c
e7f5a4e
31bdc7c
42dc912
6839647
6c659ca
1cd6c81
dcc6640
ca81015
8b77af4
5ad4cc1
d183c91
79b9700
d3d85f6
8f94610
dff84ec
5457030
68b6b66
8257a57
0f8b4f6
7fc4859
61bd641
ec5fe59
466ed14
b315afb
993ba23
894bde0
8037a19
ddca9b9
27c724e
b83af78
55deb1c
7cf85b9
4f3acf0
e8d64a4
f34b569
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 |
---|---|---|
|
@@ -2935,8 +2935,7 @@ LoopVectorizationCostModel::getVectorIntrinsicCost(CallInst *CI, | |
|
||
void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State) { | ||
// Fix widened non-induction PHIs by setting up the PHI operands. | ||
if (EnableVPlanNativePath) | ||
fixNonInductionPHIs(State); | ||
fixNonInductionPHIs(State); | ||
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. Needed because we're now using VPWidenPHI on the non-vplan-native path. Happy to split this off into an NFC as well if wanted |
||
|
||
// After vectorization, the exit blocks of the original loop will have | ||
// additional predecessors. Invalidate SCEVs for the exit phis in case SE | ||
|
@@ -7716,7 +7715,8 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan( | |
VPlanTransforms::optimizeForVFAndUF(BestVPlan, BestVF, BestUF, PSE); | ||
VPlanTransforms::simplifyRecipes(BestVPlan, *Legal->getWidestInductionType()); | ||
VPlanTransforms::removeDeadRecipes(BestVPlan); | ||
VPlanTransforms::convertToConcreteRecipes(BestVPlan); | ||
VPlanTransforms::convertToConcreteRecipes(BestVPlan, | ||
Legal->getWidestInductionType()); | ||
|
||
// Perform the actual loop transformation. | ||
VPTransformState State(&TTI, BestVF, BestUF, LI, DT, ILV.Builder, &ILV, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -881,6 +881,9 @@ class VPInstruction : public VPRecipeWithIRFlags, | |
// Extracts the first active lane of a vector, where the first operand is | ||
// the predicate, and the second operand is the vector to extract. | ||
ExtractFirstActive, | ||
// Creates a step vector starting from 0 with a step of 1. The first operand | ||
// is a dummy constant that should be used to specify the element type. | ||
StepVector, | ||
}; | ||
|
||
private: | ||
|
@@ -1757,7 +1760,9 @@ class VPWidenInductionRecipe : public VPHeaderPHIRecipe { | |
}; | ||
|
||
/// A recipe for handling phi nodes of integer and floating-point inductions, | ||
/// producing their vector values. | ||
/// producing their vector values. This won't execute any LLVM IR and will get | ||
lukel97 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// expanded later into VPWidenIntOrFpInitialRecipe, VPWidenIntOrFpPHIRecipe and | ||
/// VPWidenIntOrFpBackedgeRecipe. | ||
lukel97 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe { | ||
TruncInst *Trunc; | ||
|
||
|
@@ -1790,9 +1795,10 @@ class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe { | |
|
||
VP_CLASSOF_IMPL(VPDef::VPWidenIntOrFpInductionSC) | ||
|
||
/// Generate the vectorized and scalarized versions of the phi node as | ||
/// needed by their users. | ||
void execute(VPTransformState &State) override; | ||
void execute(VPTransformState &State) override { | ||
llvm_unreachable("cannot execute this recipe, should be expanded via " | ||
"expandVPWidenIntOrFpInductionRecipe"); | ||
} | ||
|
||
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) | ||
/// Print the recipe. | ||
|
@@ -1938,11 +1944,16 @@ class VPScalarPHIRecipe : public VPHeaderPHIRecipe { | |
/// exactly 2 incoming values, the first from the predecessor of the region and | ||
/// the second from the exiting block of the region. | ||
class VPWidenPHIRecipe : public VPSingleDefRecipe { | ||
/// Name to use for the generated IR instruction for the widened phi. | ||
std::string Name; | ||
|
||
public: | ||
/// Create a new VPWidenPHIRecipe for \p Phi with start value \p Start and | ||
/// debug location \p DL. | ||
VPWidenPHIRecipe(PHINode *Phi, VPValue *Start = nullptr, DebugLoc DL = {}) | ||
: VPSingleDefRecipe(VPDef::VPWidenPHISC, ArrayRef<VPValue *>(), Phi, DL) { | ||
/// debug location \p DL.. | ||
lukel97 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
VPWidenPHIRecipe(Instruction *Phi, VPValue *Start = nullptr, DebugLoc DL = {}, | ||
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. Why is this needed? 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. A VPWidenIntOrFpInduction's underlying value can be a trunc instruction too, but now that you mention it I think it's ok if we just pass |
||
const Twine &Name = "vec.phi") | ||
: VPSingleDefRecipe(VPDef::VPWidenPHISC, ArrayRef<VPValue *>(), Phi, DL), | ||
Name(Name.str()) { | ||
lukel97 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (Start) | ||
addOperand(Start); | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.