mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
[LoopVectorizer] Limit unroll factor in the presence of nested reductions.
If we have a scalar reduction, we can increase the critical path length if the loop we're unrolling is inside another loop. Limit, by default to 2, so the critical path only gets increased by one reduction operation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216140 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0d15213307
commit
bb819edc1f
@ -204,6 +204,11 @@ static cl::opt<bool> EnableCondStoresVectorization(
|
||||
"enable-cond-stores-vec", cl::init(false), cl::Hidden,
|
||||
cl::desc("Enable if predication of stores during vectorization."));
|
||||
|
||||
static cl::opt<unsigned> MaxNestedScalarReductionUF(
|
||||
"max-nested-scalar-reduction-unroll", cl::init(2), cl::Hidden,
|
||||
cl::desc("The maximum unroll factor to use when unrolling a scalar "
|
||||
"reduction in a nested loop."));
|
||||
|
||||
namespace {
|
||||
|
||||
// Forward declarations.
|
||||
@ -5546,6 +5551,18 @@ LoopVectorizationCostModel::selectUnrollFactor(bool OptForSize,
|
||||
unsigned StoresUF = UF / (Legal->NumStores ? Legal->NumStores : 1);
|
||||
unsigned LoadsUF = UF / (Legal->NumLoads ? Legal->NumLoads : 1);
|
||||
|
||||
// If we have a scalar reduction (vector reductions are already dealt with
|
||||
// by this point), we can increase the critical path length if the loop
|
||||
// we're unrolling is inside another loop. Limit, by default to 2, so the
|
||||
// critical path only gets increased by one reduction operation.
|
||||
if (Legal->getReductionVars()->size() &&
|
||||
TheLoop->getLoopDepth() > 1) {
|
||||
unsigned F = static_cast<unsigned>(MaxNestedScalarReductionUF);
|
||||
SmallUF = std::min(SmallUF, F);
|
||||
StoresUF = std::min(StoresUF, F);
|
||||
LoadsUF = std::min(LoadsUF, F);
|
||||
}
|
||||
|
||||
if (EnableLoadStoreRuntimeUnroll && std::max(StoresUF, LoadsUF) > SmallUF) {
|
||||
DEBUG(dbgs() << "LV: Unrolling to saturate store or load ports.\n");
|
||||
return std::max(StoresUF, LoadsUF);
|
||||
|
Loading…
x
Reference in New Issue
Block a user