@@ -1237,22 +1237,23 @@ void PassBuilder::addVectorPasses(OptimizationLevel Level,
12371237 if (EnableInferAlignmentPass)
12381238 FPM.addPass (InferAlignmentPass ());
12391239
1240- // Cleanup after loop vectorization. Simplification passes like CVP and
1241- // GVN, loop transforms, and others have already run, so it's now better to
1242- // convert to more optimized IR using more aggressive simplify CFG options.
1243- FPM.addPass (SimplifyCFGPass (SimplifyCFGOptions ()
1244- .forwardSwitchCondToPhi (true )
1245- .convertSwitchRangeToICmp (true )
1246- .convertSwitchToLookupTable (true )
1247- .needCanonicalLoops (false )
1248- .hoistCommonInsts (true )
1249- .sinkCommonInsts (true )));
1250-
12511240 // We do UnrollAndJam in a separate LPM to Unroll to ensure it happens first.
12521241 // In order for outer loop vectorization to be done, UnrollAndJam must occur before the SLPVectorizerPass.
12531242 // Placing UnrollAndJam immediately after the LoopVectorizePass when !IsFullLTO leads to improved compile times versus
1254- // placing it immediately before the SLPVectorizerPass, presumably due to analysis re-use.
1243+ // placing it immediately before the SLPVectorizerPass, due to analysis re-use.
12551244 if (EnableUnrollAndJam && PTO.LoopUnrolling ) {
1245+ // Cleanup after loop vectorization. Simplification passes like CVP and
1246+ // GVN, loop transforms, and others have already run, so it's now better to
1247+ // convert to more optimized IR using more aggressive simplify CFG options.
1248+ // SimplifyCFGPass must be run before UnrollAndJam for UnrollAndJam-SLP outer loop vectorization to happen.
1249+ FPM.addPass (SimplifyCFGPass (SimplifyCFGOptions ()
1250+ .forwardSwitchCondToPhi (true )
1251+ .convertSwitchRangeToICmp (true )
1252+ .convertSwitchToLookupTable (true )
1253+ .needCanonicalLoops (false )
1254+ .hoistCommonInsts (true )
1255+ .sinkCommonInsts (true )));
1256+
12561257 FPM.addPass (createFunctionToLoopPassAdaptor (
12571258 LoopUnrollAndJamPass (Level.getSpeedupLevel ())));
12581259 }
0 commit comments