Skip to content

Commit 38dd924

Browse files
committed
!fixup, remove extra debugLoc and move check of EVL out of transforms.
1 parent 2e4014a commit 38dd924

File tree

3 files changed

+24
-61
lines changed

3 files changed

+24
-61
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7356,8 +7356,6 @@ bool VPCostContext::skipCostComputation(Instruction *UI, bool IsVector) const {
73567356
SkipCostComputation.contains(UI);
73577357
}
73587358

7359-
bool VPCostContext::foldTailWithEVL() const { return CM.foldTailWithEVL(); }
7360-
73617359
InstructionCost
73627360
LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,
73637361
VPCostContext &CostCtx) const {
@@ -9319,8 +9317,12 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
93199317

93209318
// Transform recipes to abstract recipes if it is beneficial and clamp
93219319
// the range.
9322-
VPCostContext CostCtx(CM.TTI, *CM.TLI, Legal->getWidestInductionType(), CM);
9323-
VPlanTransforms::convertToAbstractRecipes(*Plan, CostCtx, Range);
9320+
// TODO: Enable following transform when the EVL-version of extended-reduction
9321+
// and mulacc-reduction are implemented.
9322+
if (!CM.foldTailWithEVL()) {
9323+
VPCostContext CostCtx(CM.TTI, *CM.TLI, Legal->getWidestInductionType(), CM);
9324+
VPlanTransforms::convertToAbstractRecipes(*Plan, CostCtx, Range);
9325+
}
93249326

93259327
// Interleave memory: for each Interleave Group we marked earlier as relevant
93269328
// for this VPlan, replace the Recipes widening its memory instructions with a

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -708,10 +708,6 @@ struct VPCostContext {
708708

709709
/// Returns the OperandInfo for \p V, if it is a live-in.
710710
TargetTransformInfo::OperandValueInfo getOperandInfo(VPValue *V) const;
711-
712-
/// Returns true if VP intrinsics with explicit vector length support should
713-
/// be generated in the tail folded loop.
714-
bool foldTailWithEVL() const;
715711
};
716712

717713
/// VPRecipeBase is a base class modeling a sequence of one or more output IR
@@ -2797,24 +2793,22 @@ class VPReductionEVLRecipe : public VPReductionRecipe {
27972793
class VPExtendedReductionRecipe : public VPReductionRecipe {
27982794
/// Opcode of the extend recipe will be lowered to.
27992795
Instruction::CastOps ExtOp;
2800-
/// Debug location of reduction recipe will be lowered to.
2801-
DebugLoc RedDL;
28022796

28032797
public:
28042798
VPExtendedReductionRecipe(VPReductionRecipe *R, VPWidenCastRecipe *Ext)
28052799
: VPReductionRecipe(VPDef::VPExtendedReductionSC,
28062800
R->getRecurrenceDescriptor(),
28072801
{R->getChainOp(), Ext->getOperand(0)}, R->getCondOp(),
28082802
R->isOrdered(), Ext->isNonNeg(), Ext->getDebugLoc()),
2809-
ExtOp(Ext->getOpcode()), RedDL(R->getDebugLoc()) {}
2803+
ExtOp(Ext->getOpcode()) {}
28102804

28112805
/// For cloning VPExtendedReductionRecipe.
28122806
VPExtendedReductionRecipe(VPExtendedReductionRecipe *ExtRed)
28132807
: VPReductionRecipe(
28142808
VPDef::VPExtendedReductionSC, ExtRed->getRecurrenceDescriptor(),
28152809
{ExtRed->getChainOp(), ExtRed->getVecOp()}, ExtRed->getCondOp(),
2816-
ExtRed->isOrdered(), ExtRed->isNonNeg(), ExtRed->getExtDebugLoc()),
2817-
ExtOp(ExtRed->getExtOpcode()), RedDL(ExtRed->getRedDebugLoc()) {}
2810+
ExtRed->isOrdered(), ExtRed->isNonNeg(), ExtRed->getDebugLoc()),
2811+
ExtOp(ExtRed->getExtOpcode()) {}
28182812

28192813
~VPExtendedReductionRecipe() override = default;
28202814

@@ -2849,12 +2843,6 @@ class VPExtendedReductionRecipe : public VPReductionRecipe {
28492843

28502844
/// The Opcode of extend recipe.
28512845
Instruction::CastOps getExtOpcode() const { return ExtOp; }
2852-
2853-
/// Return the debug location of the extend recipe.
2854-
DebugLoc getExtDebugLoc() const { return getDebugLoc(); }
2855-
2856-
/// Return the debug location of the reduction recipe.
2857-
DebugLoc getRedDebugLoc() const { return RedDL; }
28582846
};
28592847

28602848
/// A recipe to represent inloop MulAccumulateReduction operations, performing a
@@ -2869,13 +2857,6 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe {
28692857
/// Non-neg flag of the extend recipe.
28702858
bool IsNonNeg = false;
28712859

2872-
/// Debug location of extend recipes will be lowered to.
2873-
DebugLoc Ext0DL;
2874-
DebugLoc Ext1DL;
2875-
2876-
/// Debug location of the reduction recipe will be lowered to.
2877-
DebugLoc RedDL;
2878-
28792860
/// Is this multiply-accumulate-reduction recipe contains extend?
28802861
bool IsExtended = false;
28812862

@@ -2887,10 +2868,8 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe {
28872868
VPDef::VPMulAccumulateReductionSC, R->getRecurrenceDescriptor(),
28882869
{R->getChainOp(), Ext0->getOperand(0), Ext1->getOperand(0)},
28892870
R->getCondOp(), R->isOrdered(), Mul->hasNoUnsignedWrap(),
2890-
Mul->hasNoSignedWrap(), Mul->getDebugLoc()),
2891-
ExtOp(Ext0->getOpcode()), IsNonNeg(Ext0->isNonNeg()),
2892-
Ext0DL(Ext0->getDebugLoc()), Ext1DL(Ext1->getDebugLoc()),
2893-
RedDL(R->getDebugLoc()) {
2871+
Mul->hasNoSignedWrap(), R->getDebugLoc()),
2872+
ExtOp(Ext0->getOpcode()), IsNonNeg(Ext0->isNonNeg()) {
28942873
assert(getRecurrenceDescriptor().getOpcode() == Instruction::Add &&
28952874
"The reduction instruction in MulAccumulateteReductionRecipe must "
28962875
"be Add");
@@ -2902,8 +2881,7 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe {
29022881
VPDef::VPMulAccumulateReductionSC, R->getRecurrenceDescriptor(),
29032882
{R->getChainOp(), Mul->getOperand(0), Mul->getOperand(1)},
29042883
R->getCondOp(), R->isOrdered(), Mul->hasNoUnsignedWrap(),
2905-
Mul->hasNoSignedWrap(), Mul->getDebugLoc()),
2906-
RedDL(R->getDebugLoc()) {
2884+
Mul->hasNoSignedWrap(), R->getDebugLoc()) {
29072885
assert(getRecurrenceDescriptor().getOpcode() == Instruction::Add &&
29082886
"The reduction instruction in MulAccumulateReductionRecipe must be "
29092887
"Add");
@@ -2917,10 +2895,9 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe {
29172895
{MulAcc->getChainOp(), MulAcc->getVecOp0(), MulAcc->getVecOp1()},
29182896
MulAcc->getCondOp(), MulAcc->isOrdered(),
29192897
MulAcc->hasNoUnsignedWrap(), MulAcc->hasNoSignedWrap(),
2920-
MulAcc->getMulDebugLoc()),
2898+
MulAcc->getDebugLoc()),
29212899
ExtOp(MulAcc->getExtOpcode()), IsNonNeg(MulAcc->isNonNeg()),
2922-
Ext0DL(MulAcc->getExt0DebugLoc()), Ext1DL(MulAcc->getExt1DebugLoc()),
2923-
RedDL(MulAcc->getRedDebugLoc()), IsExtended(MulAcc->isExtended()) {}
2900+
IsExtended(MulAcc->isExtended()) {}
29242901

29252902
~VPMulAccumulateReductionRecipe() override = default;
29262903

@@ -2975,16 +2952,6 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe {
29752952
// Also drop the extra flags not in VPRecipeWithIRFlags.
29762953
this->IsNonNeg = false;
29772954
}
2978-
2979-
/// Return debug location of mul recipe.
2980-
DebugLoc getMulDebugLoc() const { return getDebugLoc(); }
2981-
2982-
/// Return debug location of extend recipe.
2983-
DebugLoc getExt0DebugLoc() const { return Ext0DL; }
2984-
DebugLoc getExt1DebugLoc() const { return Ext1DL; }
2985-
2986-
/// Return the debug location of reduction recipe.
2987-
DebugLoc getRedDebugLoc() const { return RedDL; }
29882955
};
29892956

29902957
/// VPReplicateRecipe replicates a given instruction producing multiple scalar

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,16 +1867,15 @@ static void expandVPExtendedReduction(VPExtendedReductionRecipe *ExtRed) {
18671867
if (ExtRed->isZExt())
18681868
Ext = new VPWidenCastRecipe(ExtRed->getExtOpcode(), ExtRed->getVecOp(),
18691869
ExtRed->getResultType(), ExtRed->isNonNeg(),
1870-
ExtRed->getExtDebugLoc());
1870+
ExtRed->getDebugLoc());
18711871
else
18721872
Ext = new VPWidenCastRecipe(ExtRed->getExtOpcode(), ExtRed->getVecOp(),
1873-
ExtRed->getResultType(),
1874-
ExtRed->getExtDebugLoc());
1873+
ExtRed->getResultType(), ExtRed->getDebugLoc());
18751874

18761875
// Generate VPreductionRecipe.
18771876
auto *Red = new VPReductionRecipe(
18781877
ExtRed->getRecurrenceDescriptor(), ExtRed->getChainOp(), Ext,
1879-
ExtRed->getCondOp(), ExtRed->isOrdered(), ExtRed->getRedDebugLoc());
1878+
ExtRed->getCondOp(), ExtRed->isOrdered(), ExtRed->getDebugLoc());
18801879
Ext->insertBefore(ExtRed);
18811880
Red->insertBefore(ExtRed);
18821881
ExtRed->replaceAllUsesWith(Red);
@@ -1898,10 +1897,10 @@ expandVPMulAccumulateReduction(VPMulAccumulateReductionRecipe *MulAcc) {
18981897
if (MulAcc->isZExt())
18991898
Op0 = new VPWidenCastRecipe(MulAcc->getExtOpcode(), MulAcc->getVecOp0(),
19001899
RedTy, MulAcc->isNonNeg(),
1901-
MulAcc->getExt0DebugLoc());
1900+
MulAcc->getDebugLoc());
19021901
else
19031902
Op0 = new VPWidenCastRecipe(MulAcc->getExtOpcode(), MulAcc->getVecOp0(),
1904-
RedTy, MulAcc->getExt0DebugLoc());
1903+
RedTy, MulAcc->getDebugLoc());
19051904
Op0->getDefiningRecipe()->insertBefore(MulAcc);
19061905
// Prevent reduce.add(mul(ext(A), ext(A))) generate duplicate
19071906
// VPWidenCastRecipe.
@@ -1911,14 +1910,14 @@ expandVPMulAccumulateReduction(VPMulAccumulateReductionRecipe *MulAcc) {
19111910
if (MulAcc->isZExt())
19121911
Op1 = new VPWidenCastRecipe(MulAcc->getExtOpcode(), MulAcc->getVecOp1(),
19131912
RedTy, MulAcc->isNonNeg(),
1914-
MulAcc->getExt1DebugLoc());
1913+
MulAcc->getDebugLoc());
19151914
else
19161915
Op1 = new VPWidenCastRecipe(MulAcc->getExtOpcode(), MulAcc->getVecOp1(),
1917-
RedTy, MulAcc->getExt1DebugLoc());
1916+
RedTy, MulAcc->getDebugLoc());
19181917
Op1->getDefiningRecipe()->insertBefore(MulAcc);
19191918
}
1920-
// No extends in this MulAccRecipe.
19211919
} else {
1920+
// No extends in this MulAccRecipe.
19221921
Op0 = MulAcc->getVecOp0();
19231922
Op1 = MulAcc->getVecOp1();
19241923
}
@@ -1928,13 +1927,13 @@ expandVPMulAccumulateReduction(VPMulAccumulateReductionRecipe *MulAcc) {
19281927
auto *Mul = new VPWidenRecipe(
19291928
Instruction::Mul, make_range(MulOps.begin(), MulOps.end()),
19301929
MulAcc->hasNoUnsignedWrap(), MulAcc->hasNoSignedWrap(),
1931-
MulAcc->getMulDebugLoc());
1930+
MulAcc->getDebugLoc());
19321931
Mul->insertBefore(MulAcc);
19331932

19341933
// Generate VPReductionRecipe.
19351934
auto *Red = new VPReductionRecipe(
19361935
MulAcc->getRecurrenceDescriptor(), MulAcc->getChainOp(), Mul,
1937-
MulAcc->getCondOp(), MulAcc->isOrdered(), MulAcc->getRedDebugLoc());
1936+
MulAcc->getCondOp(), MulAcc->isOrdered(), MulAcc->getDebugLoc());
19381937
Red->insertBefore(MulAcc);
19391938

19401939
MulAcc->replaceAllUsesWith(Red);
@@ -2166,11 +2165,6 @@ tryToMatchAndCreateMulAccumulateReduction(VPReductionRecipe *Red,
21662165
static void tryToCreateAbstractReductionRecipe(VPReductionRecipe *Red,
21672166
VPCostContext &Ctx,
21682167
VFRange &Range) {
2169-
// TODO: Remove EVL check when we support EVL version of
2170-
// VPExtendedReductionRecipe and VPMulAccumulateReductionRecipe.
2171-
if (Ctx.foldTailWithEVL())
2172-
return;
2173-
21742168
VPReductionRecipe *AbstractR = nullptr;
21752169

21762170
if (auto *MulAcc = tryToMatchAndCreateMulAccumulateReduction(Red, Ctx, Range))

0 commit comments

Comments
 (0)