Skip to content

Commit

Permalink
[VPlan] Update ::onlyScalarsGenerated to take IsScalable bool (NFCI).
Browse files Browse the repository at this point in the history
Instead of passing in a full VF, just pass IsScalable as bool.
  • Loading branch information
fhahn committed Feb 3, 2024
1 parent 248aeac commit 2906f36
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9237,7 +9237,7 @@ void VPWidenPointerInductionRecipe::execute(VPTransformState &State) {
auto *IVR = getParent()->getPlan()->getCanonicalIV();
PHINode *CanonicalIV = cast<PHINode>(State.get(IVR, 0));

if (onlyScalarsGenerated(State.VF)) {
if (onlyScalarsGenerated(State.VF.isScalable())) {
// This is the normalized GEP that starts counting at zero.
Value *PtrInd = State.Builder.CreateSExtOrTrunc(
CanonicalIV, IndDesc.getStep()->getType());
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Vectorize/VPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ void VPlan::execute(VPTransformState *State) {
auto *WidenPhi = cast<VPWidenPointerInductionRecipe>(&R);
// TODO: Split off the case that all users of a pointer phi are scalar
// from the VPWidenPointerInductionRecipe.
if (WidenPhi->onlyScalarsGenerated(State->VF))
if (WidenPhi->onlyScalarsGenerated(State->VF.isScalable()))
continue;

auto *GEP = cast<GetElementPtrInst>(State->get(WidenPhi, 0));
Expand Down
5 changes: 4 additions & 1 deletion llvm/lib/Transforms/Vectorize/VPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -1745,7 +1745,7 @@ class VPWidenPointerInductionRecipe : public VPHeaderPHIRecipe {
void execute(VPTransformState &State) override;

/// Returns true if only scalar values will be generated.
bool onlyScalarsGenerated(ElementCount VF);
bool onlyScalarsGenerated(bool IsScalable);

/// Returns the induction descriptor for the recipe.
const InductionDescriptor &getInductionDescriptor() const { return IndDesc; }
Expand Down Expand Up @@ -2966,6 +2966,9 @@ class VPlan {
}

bool hasVF(ElementCount VF) { return VFs.count(VF); }
bool hasScalableVF() {
return any_of(VFs, [](ElementCount VF) { return VF.isScalable(); });
}

bool hasScalarVFOnly() const { return VFs.size() == 1 && VFs[0].isScalar(); }

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1650,9 +1650,9 @@ bool VPCanonicalIVPHIRecipe::isCanonical(
return StepC && StepC->isOne();
}

bool VPWidenPointerInductionRecipe::onlyScalarsGenerated(ElementCount VF) {
bool VPWidenPointerInductionRecipe::onlyScalarsGenerated(bool IsScalable) {
return IsScalarAfterVectorization &&
(!VF.isScalable() || vputils::onlyFirstLaneUsed(this));
(!IsScalable || vputils::onlyFirstLaneUsed(this));
}

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
Expand Down

0 comments on commit 2906f36

Please sign in to comment.