-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[LV][NFC] Clean up tail-folding check for early-exit loops #133931
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 2 commits
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 |
|---|---|---|
|
|
@@ -3987,22 +3987,6 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount UserVF, unsigned UserIC) { | |
| break; | ||
| } | ||
|
|
||
| // The only loops we can vectorize without a scalar epilogue, are loops with | ||
| // a bottom-test and a single exiting block. We'd have to handle the fact | ||
| // that not every instruction executes on the last iteration. This will | ||
| // require a lane mask which varies through the vector loop body. (TODO) | ||
| if (TheLoop->getExitingBlock() != TheLoop->getLoopLatch()) { | ||
| // If there was a tail-folding hint/switch, but we can't fold the tail by | ||
| // masking, fallback to a vectorization with a scalar epilogue. | ||
| if (ScalarEpilogueStatus == CM_ScalarEpilogueNotNeededUsePredicate) { | ||
| LLVM_DEBUG(dbgs() << "LV: Cannot fold tail by masking: vectorize with a " | ||
| "scalar epilogue instead.\n"); | ||
| ScalarEpilogueStatus = CM_ScalarEpilogueAllowed; | ||
| return computeFeasibleMaxVF(MaxTC, UserVF, false); | ||
| } | ||
| return FixedScalableVFPair::getNone(); | ||
| } | ||
|
|
||
| // Now try the tail folding | ||
|
|
||
| // Invalidate interleave groups that require an epilogue if we can't mask | ||
|
|
@@ -4049,7 +4033,9 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount UserVF, unsigned UserIC) { | |
| return Rem->isZero(); | ||
| }; | ||
|
|
||
| if (MaxPowerOf2RuntimeVF > 0u) { | ||
| bool HasSingleLatchExit = | ||
|
||
| TheLoop->getExitingBlock() == TheLoop->getLoopLatch(); | ||
| if (HasSingleLatchExit && MaxPowerOf2RuntimeVF > 0u) { | ||
| assert((UserVF.isNonZero() || isPowerOf2_32(*MaxPowerOf2RuntimeVF)) && | ||
| "MaxFixedVF must be a power of 2"); | ||
| if (NoScalarEpilogueNeeded(*MaxPowerOf2RuntimeVF)) { | ||
|
|
@@ -4060,7 +4046,8 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount UserVF, unsigned UserIC) { | |
| } | ||
|
|
||
| auto ExpectedTC = getSmallBestKnownTC(PSE, TheLoop); | ||
| if (ExpectedTC && ExpectedTC <= TTI.getMinTripCountTailFoldingThreshold()) { | ||
| if (HasSingleLatchExit && ExpectedTC && | ||
| ExpectedTC <= TTI.getMinTripCountTailFoldingThreshold()) { | ||
| if (MaxPowerOf2RuntimeVF > 0u) { | ||
| // If we have a low-trip-count, and the fixed-width VF is known to divide | ||
| // the trip count but the scalable factor does not, use the fixed-width | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.