mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 00:21:03 +00:00
Add a flag to defer vectorization into a phase after the inliner and its
CGSCC pass manager. This should insulate the inlining decisions from the vectorization decisions, however it may have both compile time and code size problems so it is just an experimental option right now. Adding this based on a discussion with Arnold and it seems at least worth having this flag for us to both run some experiments to see if this strategy is workable. It may solve some of the regressions seen with the loop vectorizer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184698 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -105,6 +105,7 @@ public:
|
|||||||
bool BBVectorize;
|
bool BBVectorize;
|
||||||
bool SLPVectorize;
|
bool SLPVectorize;
|
||||||
bool LoopVectorize;
|
bool LoopVectorize;
|
||||||
|
bool LateVectorize;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// ExtensionList - This is list of all of the extensions that are registered.
|
/// ExtensionList - This is list of all of the extensions that are registered.
|
||||||
|
@@ -32,6 +32,11 @@ static cl::opt<bool>
|
|||||||
RunLoopVectorization("vectorize-loops",
|
RunLoopVectorization("vectorize-loops",
|
||||||
cl::desc("Run the Loop vectorization passes"));
|
cl::desc("Run the Loop vectorization passes"));
|
||||||
|
|
||||||
|
static cl::opt<bool>
|
||||||
|
LateVectorization("late-vectorize", cl::init(false), cl::Hidden,
|
||||||
|
cl::desc("Run the vectorization pasess late in the pass "
|
||||||
|
"pipeline (after the inliner)"));
|
||||||
|
|
||||||
static cl::opt<bool>
|
static cl::opt<bool>
|
||||||
RunSLPVectorization("vectorize-slp",
|
RunSLPVectorization("vectorize-slp",
|
||||||
cl::desc("Run the SLP vectorization passes"));
|
cl::desc("Run the SLP vectorization passes"));
|
||||||
@@ -59,6 +64,7 @@ PassManagerBuilder::PassManagerBuilder() {
|
|||||||
BBVectorize = RunBBVectorization;
|
BBVectorize = RunBBVectorization;
|
||||||
SLPVectorize = RunSLPVectorization;
|
SLPVectorize = RunSLPVectorization;
|
||||||
LoopVectorize = RunLoopVectorization;
|
LoopVectorize = RunLoopVectorization;
|
||||||
|
LateVectorize = LateVectorization;
|
||||||
}
|
}
|
||||||
|
|
||||||
PassManagerBuilder::~PassManagerBuilder() {
|
PassManagerBuilder::~PassManagerBuilder() {
|
||||||
@@ -189,8 +195,8 @@ void PassManagerBuilder::populateModulePassManager(PassManagerBase &MPM) {
|
|||||||
MPM.add(createLoopIdiomPass()); // Recognize idioms like memset.
|
MPM.add(createLoopIdiomPass()); // Recognize idioms like memset.
|
||||||
MPM.add(createLoopDeletionPass()); // Delete dead loops
|
MPM.add(createLoopDeletionPass()); // Delete dead loops
|
||||||
|
|
||||||
if (LoopVectorize && OptLevel > 1 && SizeLevel < 2)
|
if (!LateVectorize && LoopVectorize && OptLevel > 1 && SizeLevel < 2)
|
||||||
MPM.add(createLoopVectorizePass());
|
MPM.add(createLoopVectorizePass());
|
||||||
|
|
||||||
if (!DisableUnrollLoops)
|
if (!DisableUnrollLoops)
|
||||||
MPM.add(createLoopUnrollPass()); // Unroll small loops
|
MPM.add(createLoopUnrollPass()); // Unroll small loops
|
||||||
@@ -210,26 +216,70 @@ void PassManagerBuilder::populateModulePassManager(PassManagerBase &MPM) {
|
|||||||
|
|
||||||
addExtensionsToPM(EP_ScalarOptimizerLate, MPM);
|
addExtensionsToPM(EP_ScalarOptimizerLate, MPM);
|
||||||
|
|
||||||
if (SLPVectorize)
|
if (!LateVectorize) {
|
||||||
MPM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains.
|
if (SLPVectorize)
|
||||||
|
MPM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains.
|
||||||
|
|
||||||
if (BBVectorize) {
|
if (BBVectorize) {
|
||||||
MPM.add(createBBVectorizePass());
|
MPM.add(createBBVectorizePass());
|
||||||
MPM.add(createInstructionCombiningPass());
|
MPM.add(createInstructionCombiningPass());
|
||||||
if (OptLevel > 1 && UseGVNAfterVectorization)
|
if (OptLevel > 1 && UseGVNAfterVectorization)
|
||||||
MPM.add(createGVNPass()); // Remove redundancies
|
MPM.add(createGVNPass()); // Remove redundancies
|
||||||
else
|
else
|
||||||
MPM.add(createEarlyCSEPass()); // Catch trivial redundancies
|
MPM.add(createEarlyCSEPass()); // Catch trivial redundancies
|
||||||
|
|
||||||
// BBVectorize may have significantly shortened a loop body; unroll again.
|
// BBVectorize may have significantly shortened a loop body; unroll again.
|
||||||
if (!DisableUnrollLoops)
|
if (!DisableUnrollLoops)
|
||||||
MPM.add(createLoopUnrollPass());
|
MPM.add(createLoopUnrollPass());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MPM.add(createAggressiveDCEPass()); // Delete dead instructions
|
MPM.add(createAggressiveDCEPass()); // Delete dead instructions
|
||||||
MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
|
MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
|
||||||
MPM.add(createInstructionCombiningPass()); // Clean up after everything.
|
MPM.add(createInstructionCombiningPass()); // Clean up after everything.
|
||||||
|
|
||||||
|
// As an experimental mode, run any vectorization passes in a separate
|
||||||
|
// pipeline from the CGSCC pass manager that runs iteratively with the
|
||||||
|
// inliner.
|
||||||
|
if (LateVectorize) {
|
||||||
|
// FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC
|
||||||
|
// pass manager that we are specifically trying to avoid. To prevent this
|
||||||
|
// we must insert a no-op module pass to reset the pass manager.
|
||||||
|
MPM.add(createBarrierNoopPass());
|
||||||
|
|
||||||
|
// Add the various vectorization passes and relevant cleanup passes for
|
||||||
|
// them since we are no longer in the middle of the main scalar pipeline.
|
||||||
|
if (LoopVectorize && OptLevel > 1 && SizeLevel < 2) {
|
||||||
|
MPM.add(createLoopVectorizePass());
|
||||||
|
|
||||||
|
if (!DisableUnrollLoops)
|
||||||
|
MPM.add(createLoopUnrollPass()); // Unroll small loops
|
||||||
|
|
||||||
|
// FIXME: Is this necessary/useful? Should we also do SimplifyCFG?
|
||||||
|
MPM.add(createInstructionCombiningPass());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SLPVectorize) {
|
||||||
|
MPM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains.
|
||||||
|
|
||||||
|
// FIXME: Is this necessary/useful? Should we also do SimplifyCFG?
|
||||||
|
MPM.add(createInstructionCombiningPass());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (BBVectorize) {
|
||||||
|
MPM.add(createBBVectorizePass());
|
||||||
|
MPM.add(createInstructionCombiningPass());
|
||||||
|
if (OptLevel > 1 && UseGVNAfterVectorization)
|
||||||
|
MPM.add(createGVNPass()); // Remove redundancies
|
||||||
|
else
|
||||||
|
MPM.add(createEarlyCSEPass()); // Catch trivial redundancies
|
||||||
|
|
||||||
|
// BBVectorize may have significantly shortened a loop body; unroll again.
|
||||||
|
if (!DisableUnrollLoops)
|
||||||
|
MPM.add(createLoopUnrollPass());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!DisableUnitAtATime) {
|
if (!DisableUnitAtATime) {
|
||||||
// FIXME: We shouldn't bother with this anymore.
|
// FIXME: We shouldn't bother with this anymore.
|
||||||
MPM.add(createStripDeadPrototypesPass()); // Get rid of dead prototypes
|
MPM.add(createStripDeadPrototypesPass()); // Get rid of dead prototypes
|
||||||
|
Reference in New Issue
Block a user