Hi, If we add multiple loop passes to the pass manager in PassManagerBuilder.cpp consecutively without any func/module pass in between, I used to think they would belong to the same loop pass manager. But it does not seem to be the case. For example for this code snippet PM.add(createIndVarSimplifyPass()); // Canonicalize indvars MPM.add(createLoopIdiomPass()); // Recognize idioms like memset. addExtensionsToPM(EP_LateLoopOptimizations, MPM); MPM.add(createLoopDeletionPass()); // Delete dead loops .. if (!DisableUnrollLoops) MPM.add(createSimpleLoopUnrollPass(OptLevel)); // Unroll small loops I see -debug-pass=Structure output: Scalar Evolution Analysis Loop Pass Manager Induction Variable Simplification Recognize loop idioms Delete dead loops Unroll loops MergedLoadStoreMotion Which is in line to what I thought. However for this code snippet: if (EnableUnrollAndJam) { // Unroll and Jam. We do this before unroll but need to be in a separate // loop pass manager in order for the outer loop to be processed by // unroll and jam before the inner loop is unrolled. MPM.add(createLoopUnrollAndJamPass(OptLevel)); } MPM.add(createLoopUnrollPass(OptLevel)); // Unroll small loops I see: Loop-Closed SSA Form Pass Loop Pass Manager Unroll and Jam loops Loop Pass Manager Unroll loops Lazy Branch Probability Analysis Here two different loop pass managers were created. What is the difference in between these two cases? How was the loop pass manager split up in the second case? -- Regards Bhatu -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180809/c4666dbe/attachment.html>
Ping! On Thu, Aug 9, 2018 at 2:46 PM, Bhatu <cs12b1010 at iith.ac.in> wrote:> Hi, > > If we add multiple loop passes to the pass manager in > PassManagerBuilder.cpp consecutively without any func/module pass in > between, I used to think they would belong to the same loop pass manager. > But it does not seem to be the case. > > For example for this code snippet > PM.add(createIndVarSimplifyPass()); // Canonicalize indvars > MPM.add(createLoopIdiomPass()); // Recognize idioms like > memset. > addExtensionsToPM(EP_LateLoopOptimizations, MPM); > MPM.add(createLoopDeletionPass()); // Delete dead loops > .. > if (!DisableUnrollLoops) > MPM.add(createSimpleLoopUnrollPass(OptLevel)); // Unroll small > loops > > I see -debug-pass=Structure output: > Scalar Evolution Analysis > Loop Pass Manager > Induction Variable Simplification > Recognize loop idioms > Delete dead loops > Unroll loops > MergedLoadStoreMotion > > Which is in line to what I thought. However for this code snippet: > if (EnableUnrollAndJam) { > // Unroll and Jam. We do this before unroll but need to be in a > separate > // loop pass manager in order for the outer loop to be processed by > // unroll and jam before the inner loop is unrolled. > MPM.add(createLoopUnrollAndJamPass(OptLevel)); > } > > MPM.add(createLoopUnrollPass(OptLevel)); // Unroll small loops > > I see: > Loop-Closed SSA Form Pass > Loop Pass Manager > Unroll and Jam loops > Loop Pass Manager > Unroll loops > Lazy Branch Probability Analysis > > Here two different loop pass managers were created. What is the difference > in between these two cases? How was the loop pass manager split up in the > second case? > > > -- > Regards > Bhatu >-- Regards Bhatu -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180816/8bc08452/attachment.html>
Michael Kruse via llvm-dev
2018-Aug-16 15:58 UTC
[llvm-dev] Legacy Loop Pass Manager question
This usually happens if an analysis required by LoopInfo is not preserved. However, LoopDeletion, LoopUnrollAndJam and LoopUnroll's getAnalysisUsage all call getLoopAnalysisUsage, which add the same pass preservations. I'd debug and step through the loop manager's code to find what makes the cases different. Michael Am Do., 9. Aug. 2018 um 04:17 Uhr schrieb Bhatu via llvm-dev <llvm-dev at lists.llvm.org>:> > Hi, > > If we add multiple loop passes to the pass manager in PassManagerBuilder.cpp consecutively without any func/module pass in between, I used to think they would belong to the same loop pass manager. But it does not seem to be the case. > > For example for this code snippet > PM.add(createIndVarSimplifyPass()); // Canonicalize indvars > MPM.add(createLoopIdiomPass()); // Recognize idioms like memset. > addExtensionsToPM(EP_LateLoopOptimizations, MPM); > MPM.add(createLoopDeletionPass()); // Delete dead loops > .. > if (!DisableUnrollLoops) > MPM.add(createSimpleLoopUnrollPass(OptLevel)); // Unroll small loops > > I see -debug-pass=Structure output: > Scalar Evolution Analysis > Loop Pass Manager > Induction Variable Simplification > Recognize loop idioms > Delete dead loops > Unroll loops > MergedLoadStoreMotion > > Which is in line to what I thought. However for this code snippet: > if (EnableUnrollAndJam) { > // Unroll and Jam. We do this before unroll but need to be in a separate > // loop pass manager in order for the outer loop to be processed by > // unroll and jam before the inner loop is unrolled. > MPM.add(createLoopUnrollAndJamPass(OptLevel)); > } > > MPM.add(createLoopUnrollPass(OptLevel)); // Unroll small loops > > I see: > Loop-Closed SSA Form Pass > Loop Pass Manager > Unroll and Jam loops > Loop Pass Manager > Unroll loops > Lazy Branch Probability Analysis > > Here two different loop pass managers were created. What is the difference in between these two cases? How was the loop pass manager split up in the second case? > > > -- > Regards > Bhatu > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Thanks for the pointers Michael. I'll investigate that and report back with my findings. On Thu, 16 Aug 2018, 21:29 Michael Kruse, <llvmdev at meinersbur.de> wrote:> This usually happens if an analysis required by LoopInfo is not > preserved. However, LoopDeletion, LoopUnrollAndJam and LoopUnroll's > getAnalysisUsage all call getLoopAnalysisUsage, which add the same > pass preservations. > > I'd debug and step through the loop manager's code to find what makes > the cases different. > > Michael > > Am Do., 9. Aug. 2018 um 04:17 Uhr schrieb Bhatu via llvm-dev > <llvm-dev at lists.llvm.org>: > > > > Hi, > > > > If we add multiple loop passes to the pass manager in > PassManagerBuilder.cpp consecutively without any func/module pass in > between, I used to think they would belong to the same loop pass manager. > But it does not seem to be the case. > > > > For example for this code snippet > > PM.add(createIndVarSimplifyPass()); // Canonicalize indvars > > MPM.add(createLoopIdiomPass()); // Recognize idioms like > memset. > > addExtensionsToPM(EP_LateLoopOptimizations, MPM); > > MPM.add(createLoopDeletionPass()); // Delete dead loops > > .. > > if (!DisableUnrollLoops) > > MPM.add(createSimpleLoopUnrollPass(OptLevel)); // Unroll small > loops > > > > I see -debug-pass=Structure output: > > Scalar Evolution Analysis > > Loop Pass Manager > > Induction Variable Simplification > > Recognize loop idioms > > Delete dead loops > > Unroll loops > > MergedLoadStoreMotion > > > > Which is in line to what I thought. However for this code snippet: > > if (EnableUnrollAndJam) { > > // Unroll and Jam. We do this before unroll but need to be in a > separate > > // loop pass manager in order for the outer loop to be processed by > > // unroll and jam before the inner loop is unrolled. > > MPM.add(createLoopUnrollAndJamPass(OptLevel)); > > } > > > > MPM.add(createLoopUnrollPass(OptLevel)); // Unroll small loops > > > > I see: > > Loop-Closed SSA Form Pass > > Loop Pass Manager > > Unroll and Jam loops > > Loop Pass Manager > > Unroll loops > > Lazy Branch Probability Analysis > > > > Here two different loop pass managers were created. What is the > difference in between these two cases? How was the loop pass manager split > up in the second case? > > > > > > -- > > Regards > > Bhatu > > _______________________________________________ > > LLVM Developers mailing list > > llvm-dev at lists.llvm.org > > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180816/0c1bd425/attachment.html>