Index: include/llvm/Transforms/Scalar/SimplifyCFG.h =================================================================== --- include/llvm/Transforms/Scalar/SimplifyCFG.h +++ include/llvm/Transforms/Scalar/SimplifyCFG.h @@ -35,13 +35,14 @@ /// rather than optimal IR. That is, by default we bypass transformations that /// are likely to improve performance but make analysis for other passes more /// difficult. - SimplifyCFGPass() - : SimplifyCFGPass(SimplifyCFGOptions() - .forwardSwitchCondToPhi(false) - .convertSwitchToLookupTable(false) - .needCanonicalLoops(true) - .sinkCommonInsts(false)) {} + SimplifyCFGPass() : SimplifyCFGPass(false) {} + explicit SimplifyCFGPass(bool optimizing) : SimplifyCFGPass( + SimplifyCFGOptions() + .forwardSwitchCondToPhi(optimizing) + .convertSwitchToLookupTable(optimizing) + .needCanonicalLoops(!optimizing) + .sinkCommonInsts(optimizing)) {} /// Construct a pass with optional optimizations. SimplifyCFGPass(const SimplifyCFGOptions &PassOptions); Index: lib/Passes/PassBuilder.cpp =================================================================== --- lib/Passes/PassBuilder.cpp +++ lib/Passes/PassBuilder.cpp @@ -796,11 +796,7 @@ // convert to more optimized IR using more aggressive simplify CFG options. // The extra sinking transform can create larger basic blocks, so do this // before SLP vectorization. - OptimizePM.addPass(SimplifyCFGPass(SimplifyCFGOptions(). - forwardSwitchCondToPhi(true). - convertSwitchToLookupTable(true). - needCanonicalLoops(false). - sinkCommonInsts(true))); + OptimizePM.addPass(SimplifyCFGPass(/*optimizing=*/true)); // Optimize parallel scalar instruction chains into SIMD instructions. OptimizePM.addPass(SLPVectorizerPass()); Index: lib/Passes/PassRegistry.def =================================================================== --- lib/Passes/PassRegistry.def +++ lib/Passes/PassRegistry.def @@ -203,6 +203,7 @@ FUNCTION_PASS("reassociate", ReassociatePass()) FUNCTION_PASS("sccp", SCCPPass()) FUNCTION_PASS("simplify-cfg", SimplifyCFGPass()) +FUNCTION_PASS("simplify-cfg-opt", SimplifyCFGPass(true)) FUNCTION_PASS("sink", SinkingPass()) FUNCTION_PASS("slp-vectorizer", SLPVectorizerPass()) FUNCTION_PASS("speculative-execution", SpeculativeExecutionPass())