Only use SROA for llvm 3.7 or newer.
This commit is contained in:
26
opt.cpp
26
opt.cpp
@@ -612,7 +612,11 @@ Optimize(llvm::Module *module, int optLevel) {
|
||||
optPM.add(llvm::createBasicAAWrapperPass());
|
||||
#endif
|
||||
optPM.add(llvm::createCFGSimplificationPass());
|
||||
#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
|
||||
optPM.add(llvm::createScalarReplAggregatesPass());
|
||||
#else
|
||||
optPM.add(llvm::createSROAPass());
|
||||
#endif
|
||||
optPM.add(llvm::createEarlyCSEPass());
|
||||
optPM.add(llvm::createLowerExpectIntrinsicPass());
|
||||
|
||||
@@ -641,11 +645,17 @@ Optimize(llvm::Module *module, int optLevel) {
|
||||
// Max struct size threshold for scalar replacement is
|
||||
// 1) 4 fields (r,g,b,w)
|
||||
// 2) field size: vectorWidth * sizeof(float)
|
||||
#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
|
||||
const int field_limit = 4;
|
||||
int sr_threshold = g->target->getVectorWidth() * sizeof(float) * field_limit;
|
||||
#endif
|
||||
|
||||
// On to more serious optimizations
|
||||
#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
|
||||
optPM.add(llvm::createScalarReplAggregatesPass(sr_threshold));
|
||||
#else
|
||||
optPM.add(llvm::createSROAPass());
|
||||
#endif
|
||||
optPM.add(llvm::createInstructionCombiningPass());
|
||||
optPM.add(llvm::createCFGSimplificationPass());
|
||||
optPM.add(llvm::createPromoteMemoryToRegisterPass());
|
||||
@@ -678,7 +688,11 @@ Optimize(llvm::Module *module, int optLevel) {
|
||||
optPM.add(llvm::createInstructionCombiningPass(), 241);
|
||||
optPM.add(llvm::createJumpThreadingPass());
|
||||
optPM.add(llvm::createCFGSimplificationPass());
|
||||
#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
|
||||
optPM.add(llvm::createScalarReplAggregatesPass(sr_threshold));
|
||||
#else
|
||||
optPM.add(llvm::createSROAPass());
|
||||
#endif
|
||||
optPM.add(llvm::createInstructionCombiningPass());
|
||||
optPM.add(llvm::createTailCallEliminationPass());
|
||||
|
||||
@@ -726,7 +740,11 @@ Optimize(llvm::Module *module, int optLevel) {
|
||||
|
||||
optPM.add(llvm::createFunctionInliningPass());
|
||||
optPM.add(llvm::createArgumentPromotionPass());
|
||||
optPM.add(llvm::createScalarReplAggregatesPass(sr_threshold, false));
|
||||
#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
|
||||
optPM.add(llvm::createScalarReplAggregatesPass(sr_threshold));
|
||||
#else
|
||||
optPM.add(llvm::createSROAPass());
|
||||
#endif
|
||||
optPM.add(llvm::createInstructionCombiningPass());
|
||||
optPM.add(CreateInstructionSimplifyPass());
|
||||
optPM.add(llvm::createCFGSimplificationPass());
|
||||
@@ -780,7 +798,11 @@ Optimize(llvm::Module *module, int optLevel) {
|
||||
optPM.add(llvm::createCFGSimplificationPass());
|
||||
// Here clang has an experimental pass SROAPass instead of
|
||||
// ScalarReplAggregatesPass. We should add it in the future.
|
||||
optPM.add(llvm::createScalarReplAggregatesPass());
|
||||
#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
|
||||
optPM.add(llvm::createScalarReplAggregatesPass(sr_threshold));
|
||||
#else
|
||||
optPM.add(llvm::createSROAPass());
|
||||
#endif
|
||||
optPM.add(llvm::createEarlyCSEPass());
|
||||
optPM.add(llvm::createLowerExpectIntrinsicPass());
|
||||
optPM.add(llvm::createTypeBasedAliasAnalysisPass());
|
||||
|
||||
Reference in New Issue
Block a user