[llvm] [Analysis] Avoid running transform passes that have just been run (PR #112092)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 14 03:04:03 PDT 2024


================
@@ -5538,8 +5539,15 @@ void InstCombinePass::printPipeline(
   OS << '>';
 }
 
+char InstCombinePass::ID = 0;
+
 PreservedAnalyses InstCombinePass::run(Function &F,
                                        FunctionAnalysisManager &AM) {
+  auto &LRT = AM.getResult<LastRunTrackingAnalysis>(F);
+  // No changes since last InstCombine pass, exit early.
+  if (LRT.shouldSkip(&ID, Options))
+    return PreservedAnalyses::all();
----------------
dtcxzyw wrote:

I don't agree. Only some canonicalization/cleanup passes benefit from this optimization. Moving the logic into PassManager may introduce higher overhead.

BTW, we cannot do this since InstCombine/SimplifyCFG have pass parameters.


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


More information about the llvm-commits mailing list