[llvm] [LoopInterchange] Hoist isCompuatableLoopNest() in the control flow (PR #124247)

Ryotaro Kasuga via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 28 04:20:42 PST 2025


================
@@ -1756,10 +1754,23 @@ PreservedAnalyses LoopInterchangePass::run(LoopNest &LN,
   // Ensure minimum depth of the loop nest to do the interchange.
   if (!hasSupportedLoopDepth(LoopList, ORE))
     return PreservedAnalyses::all();
+  // Ensure computable loop nest.
+  if (!isComputableLoopNest(&AR.SE, LoopList)) {
+    LLVM_DEBUG(dbgs() << "Not valid loop candidate for interchange\n");
+    return PreservedAnalyses::all();
+  }
+
+  ORE.emit([&]() {
+    return OptimizationRemark(DEBUG_TYPE, "Dependence",
----------------
kasuga-fj wrote:

I don't think it's appropriate to use `OptimizationRemark` here. IIUIC, it is used to communicate the result of the transformation. If you want to use optimization remarks, `OptimizationRemarkAnalysis` seems to be better.
Also, I think optimization remarks are what should show the "hints" to the user, so printing them as debug output with `dbgs()` seems to be appropriate in this case.

https://github.com/llvm/llvm-project/pull/124247


More information about the llvm-commits mailing list