summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Vectorize
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2019-08-07 21:44:14 +0000
committerCraig Topper <craig.topper@intel.com>2019-08-07 21:44:14 +0000
commit005b22855e6678e5e0e5ab8a324ff3f8fa4c5cd8 (patch)
treeaddbb3fca969e7e0e9b67733e9ad93e9fef553f5 /llvm/lib/Transforms/Vectorize
parentb80c4c82d6d4682d2cb177cdffd1aa951322d26b (diff)
downloadbcm5719-llvm-005b22855e6678e5e0e5ab8a324ff3f8fa4c5cd8.tar.gz
bcm5719-llvm-005b22855e6678e5e0e5ab8a324ff3f8fa4c5cd8.zip
[LoopVectorize][X86] Clamp interleave factor if we have a known constant trip count that is less than VF*interleave
If we know the trip count, we should make sure the interleave factor won't cause the vectorized loop to exceed it. Improves one of the cases from PR42674 Differential Revision: https://reviews.llvm.org/D65896 llvm-svn: 368215
Diffstat (limited to 'llvm/lib/Transforms/Vectorize')
-rw-r--r--llvm/lib/Transforms/Vectorize/LoopVectorize.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index dd28b18258f..1f8cbf7f340 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -5121,6 +5121,14 @@ unsigned LoopVectorizationCostModel::selectInterleaveCount(unsigned VF,
MaxInterleaveCount = ForceTargetMaxVectorInterleaveFactor;
}
+ // If the trip count is constant, limit the interleave count to be less than
+ // the trip count divided by VF.
+ if (TC > 0) {
+ assert(TC >= VF && "VF exceeds trip count?");
+ if ((TC / VF) < MaxInterleaveCount)
+ MaxInterleaveCount = (TC / VF);
+ }
+
// If we did not calculate the cost for VF (because the user selected the VF)
// then we calculate the cost of VF here.
if (LoopCost == 0)
@@ -5129,7 +5137,7 @@ unsigned LoopVectorizationCostModel::selectInterleaveCount(unsigned VF,
assert(LoopCost && "Non-zero loop cost expected");
// Clamp the calculated IC to be between the 1 and the max interleave count
- // that the target allows.
+ // that the target and trip count allows.
if (IC > MaxInterleaveCount)
IC = MaxInterleaveCount;
else if (IC < 1)
OpenPOWER on IntegriCloud