[PATCH] D78630: [LV] Clamp the Unroll Factor to at least 1
Simon Moll via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 22 05:55:18 PDT 2020
simoll created this revision.
simoll added reviewers: fhahn, hsaito, Ayal, mkuper.
Herald added subscribers: llvm-commits, rkruppe, hiraditya.
Herald added a project: LLVM.
LV requires the unroll factor (UF) to be >= 1. This patch adds an explicit assertion for this and fixes a case in the cost model where the UF was set to zero. This was exposed by an out-of-tree TTI implementation that reported zero scores for candidate vectorization factors.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D78630
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
@@ -5300,7 +5300,8 @@
// If trip count is known or estimated compile time constant, limit the
// interleave count to be less than the trip count divided by VF.
if (BestKnownTC) {
- MaxInterleaveCount = std::min(*BestKnownTC / VF, MaxInterleaveCount);
+ MaxInterleaveCount =
+ std::max(1u, std::min(*BestKnownTC / VF, MaxInterleaveCount));
}
// If we did not calculate the cost for VF (because the user selected the VF)
@@ -5321,6 +5322,7 @@
// benefit from interleaving.
if (VF > 1 && !Legal->getReductionVars().empty()) {
LLVM_DEBUG(dbgs() << "LV: Interleaving because of reductions.\n");
+ assert(IC > 0);
return IC;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78630.259252.patch
Type: text/x-patch
Size: 902 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200422/c2aac3a9/attachment.bin>
More information about the llvm-commits
mailing list