summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorArnold Schwaighofer <aschwaighofer@apple.com>2014-10-26 21:50:58 +0000
committerArnold Schwaighofer <aschwaighofer@apple.com>2014-10-26 21:50:58 +0000
commiteb1a38fa73b3250683a95875caffa1eac0ae292a (patch)
tree543929cf5600424b70bad9a9645ac54c4a35ab3b /llvm/lib
parent01db53848e700917583344a20d118ec860629dc5 (diff)
downloadbcm5719-llvm-eb1a38fa73b3250683a95875caffa1eac0ae292a.tar.gz
bcm5719-llvm-eb1a38fa73b3250683a95875caffa1eac0ae292a.zip
Add an option to the LTO code generator to disable vectorization during LTO
We used to always vectorize (slp and loop vectorize) in the LTO pass pipeline. r220345 changed it so that we used the PassManager's fields 'LoopVectorize' and 'SLPVectorize' out of the desire to be able to disable vectorization using the cl::opt flags 'vectorize-loops'/'slp-vectorize' which the before mentioned fields default to. Unfortunately, this turns off vectorization because those fields default to false. This commit adds flags to the LTO library to disable lto vectorization which reconciles the desire to optionally disable vectorization during LTO and the desired behavior of defaulting to enabled vectorization. We really want tools to set PassManager flags directly to enable/disable vectorization and not go the route via cl::opt flags *in* PassManagerBuilder.cpp. llvm-svn: 220652
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/LTO/LTOCodeGenerator.cpp12
-rw-r--r--llvm/lib/Transforms/IPO/PassManagerBuilder.cpp2
2 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index bb85cfde501..4911a260d79 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -188,6 +188,7 @@ bool LTOCodeGenerator::compile_to_file(const char** name,
bool disableOpt,
bool disableInline,
bool disableGVNLoadPRE,
+ bool disableVectorization,
std::string& errMsg) {
// make unique temp .o file to put generated object file
SmallString<128> Filename;
@@ -202,8 +203,9 @@ bool LTOCodeGenerator::compile_to_file(const char** name,
// generate object file
tool_output_file objFile(Filename.c_str(), FD);
- bool genResult = generateObjectFile(objFile.os(), disableOpt, disableInline,
- disableGVNLoadPRE, errMsg);
+ bool genResult =
+ generateObjectFile(objFile.os(), disableOpt, disableInline,
+ disableGVNLoadPRE, disableVectorization, errMsg);
objFile.os().close();
if (objFile.os().has_error()) {
objFile.os().clear_error();
@@ -226,10 +228,11 @@ const void* LTOCodeGenerator::compile(size_t* length,
bool disableOpt,
bool disableInline,
bool disableGVNLoadPRE,
+ bool disableVectorization,
std::string& errMsg) {
const char *name;
if (!compile_to_file(&name, disableOpt, disableInline, disableGVNLoadPRE,
- errMsg))
+ disableVectorization, errMsg))
return nullptr;
// read .o file into memory buffer
@@ -441,6 +444,7 @@ bool LTOCodeGenerator::generateObjectFile(raw_ostream &out,
bool DisableOpt,
bool DisableInline,
bool DisableGVNLoadPRE,
+ bool DisableVectorization,
std::string &errMsg) {
if (!this->determineTarget(errMsg))
return false;
@@ -459,6 +463,8 @@ bool LTOCodeGenerator::generateObjectFile(raw_ostream &out,
Triple TargetTriple(TargetMach->getTargetTriple());
PassManagerBuilder PMB;
PMB.DisableGVNLoadPRE = DisableGVNLoadPRE;
+ PMB.LoopVectorize = !DisableVectorization;
+ PMB.SLPVectorize = !DisableVectorization;
if (!DisableInline)
PMB.Inliner = createFunctionInliningPass();
PMB.LibraryInfo = new TargetLibraryInfo(TargetTriple);
diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
index 92f49d3f645..da85a91c78a 100644
--- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -444,7 +444,7 @@ void PassManagerBuilder::addLTOOptimizationPasses(PassManagerBase &PM) {
// More loops are countable; try to optimize them.
PM.add(createIndVarSimplifyPass());
PM.add(createLoopDeletionPass());
- PM.add(createLoopVectorizePass(DisableUnrollLoops, LoopVectorize));
+ PM.add(createLoopVectorizePass(true, LoopVectorize));
// More scalar chains could be vectorized due to more alias information
if (RunSLPAfterLoopVectorization)
OpenPOWER on IntegriCloud