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

Sjoerd Meijer via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 30 02:24:53 PST 2025


================
@@ -1761,10 +1759,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 OptimizationRemarkAnalysis(DEBUG_TYPE, "Dependence",
+                                      LN.getOutermostLoop().getStartLoc(),
+                                      LN.getOutermostLoop().getHeader())
+           << "Computed dependence info, invoking the transform.";
----------------
sjoerdmeijer wrote:

This is a user-facing optimisation remark, but it is quite "technical".
Correct me if I am wrong, but I think what we are trying to say here is equivalent to this:

    LLVM_DEBUG(dbgs() << "Loops are legal to interchange\n");

in function `processLoop` on line `525`.

My question is: can we turn this debug message into an OptimisationRemark and not need this new opt remark? I think this could serve two purposes: it is actually interesting information for users, and does it help you with knowing that "dep info has been computed, the transformation is legal"?

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


More information about the llvm-commits mailing list