[PATCH] D93677: [LV] Use ScalarEvolution::getURemExpr to reduce duplication.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 22 01:39:53 PST 2020
fhahn created this revision.
fhahn added reviewers: SjoerdMeijer, gilr.
Herald added a subscriber: hiraditya.
fhahn requested review of this revision.
Herald added a project: LLVM.
ScalarEvolution should be able to handle both constant and variable trip
counts using getURemExpr, so we do not have to handle them separately.
This is a small simplification of a56280094e08 <https://reviews.llvm.org/rGa56280094e08792516b035390a946ea337a27b97>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D93677
Files:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -5506,20 +5506,15 @@
"MaxVF must be a power of 2");
unsigned MaxVFtimesIC =
UserIC ? MaxVF.getFixedValue() * UserIC : MaxVF.getFixedValue();
- if (TC > 0 && TC % MaxVFtimesIC == 0) {
- // Accept MaxVF if we do not have a tail.
- LLVM_DEBUG(dbgs() << "LV: No tail will remain for any chosen VF.\n");
- return MaxVF;
- }
-
// Avoid tail folding if the trip count is known to be a multiple of any VF we
// chose.
ScalarEvolution *SE = PSE.getSE();
const SCEV *BackedgeTakenCount = PSE.getBackedgeTakenCount();
const SCEV *ExitCount = SE->getAddExpr(
BackedgeTakenCount, SE->getOne(BackedgeTakenCount->getType()));
- unsigned TCisMultipleOf = 1 << SE->GetMinTrailingZeros(ExitCount);
- if (TCisMultipleOf % MaxVFtimesIC == 0) {
+ const SCEV *Rem = SE->getURemExpr(
+ ExitCount, SE->getConstant(BackedgeTakenCount->getType(), MaxVFtimesIC));
+ if (Rem->isZero()) {
// Accept MaxVF if we do not have a tail.
LLVM_DEBUG(dbgs() << "LV: No tail will remain for any chosen VF.\n");
return MaxVF;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93677.313263.patch
Type: text/x-patch
Size: 1293 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201222/d2ff5836/attachment.bin>
More information about the llvm-commits
mailing list