[PATCH] D96019: [LoopVectorize] NFC: Change selectVectorizationFactor to work on ElementCount.
Sander de Smalen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 11 00:48:43 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbe9bbb57f473: [LoopVectorize] NFC: Change selectVectorizationFactor to work on ElementCount. (authored by sdesmalen).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96019/new/
https://reviews.llvm.org/D96019
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
@@ -5834,7 +5834,7 @@
LLVM_DEBUG(dbgs() << "LV: Scalar loop costs: " << ExpectedCost << ".\n");
assert(ExpectedCost.isValid() && "Unexpected invalid cost for scalar loop");
- unsigned Width = 1;
+ auto Width = ElementCount::getFixed(1);
const float ScalarCost = *ExpectedCost.getValue();
float Cost = ScalarCost;
@@ -5846,13 +5846,14 @@
Cost = std::numeric_limits<float>::max();
}
- for (unsigned i = 2; i <= MaxVF.getFixedValue(); i *= 2) {
+ for (auto i = ElementCount::getFixed(2); ElementCount::isKnownLE(i, MaxVF);
+ i *= 2) {
// Notice that the vector loop needs to be executed less times, so
// we need to divide the cost of the vector loops by the width of
// the vector elements.
- VectorizationCostTy C = expectedCost(ElementCount::getFixed(i));
+ VectorizationCostTy C = expectedCost(i);
assert(C.first.isValid() && "Unexpected invalid cost for vector loop");
- float VectorCost = *C.first.getValue() / (float)i;
+ float VectorCost = *C.first.getValue() / (float)i.getFixedValue();
LLVM_DEBUG(dbgs() << "LV: Vector loop of width " << i
<< " costs: " << (int)VectorCost << ".\n");
if (!C.second && !ForceVectorization) {
@@ -5865,7 +5866,7 @@
// If profitable add it to ProfitableVF list.
if (VectorCost < ScalarCost) {
ProfitableVFs.push_back(VectorizationFactor(
- {ElementCount::getFixed(i), (unsigned)VectorCost}));
+ {i, (unsigned)VectorCost}));
}
if (VectorCost < Cost) {
@@ -5878,16 +5879,16 @@
reportVectorizationFailure("There are conditional stores.",
"store that is conditionally executed prevents vectorization",
"ConditionalStore", ORE, TheLoop);
- Width = 1;
+ Width = ElementCount::getFixed(1);
Cost = ScalarCost;
}
- LLVM_DEBUG(if (ForceVectorization && Width > 1 && Cost >= ScalarCost) dbgs()
+ LLVM_DEBUG(if (ForceVectorization && !Width.isScalar() && Cost >= ScalarCost) dbgs()
<< "LV: Vectorization seems to be not beneficial, "
<< "but was forced by a user.\n");
LLVM_DEBUG(dbgs() << "LV: Selecting VF: " << Width << ".\n");
- VectorizationFactor Factor = {ElementCount::getFixed(Width),
- (unsigned)(Width * Cost)};
+ VectorizationFactor Factor = {Width,
+ (unsigned)(Width.getKnownMinValue() * Cost)};
return Factor;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96019.322913.patch
Type: text/x-patch
Size: 2669 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210211/b8424c1b/attachment.bin>
More information about the llvm-commits
mailing list