[llvm] [LoopFuse] Don't preserve SCEV analysis (PR #153547)

Madhur Amilkanthwar via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 14 00:23:02 PDT 2025


https://github.com/madhur13490 created https://github.com/llvm/llvm-project/pull/153547

This patch fixes the issue while verifying SCEV.
As the loops are fused, SCEV information is not valid, and rather than recomputing it in the pass,
We should prefer to let the pass manager recompute it for us when the next pass request it.

When there is no fusion, all analyses are preserved.
Fixes #115279

>From 101b07c802583cb1c8152c48c5c7d6d0c5fcc3c6 Mon Sep 17 00:00:00 2001
From: Madhur Amilkanthwar <madhura at nvidia.com>
Date: Thu, 14 Aug 2025 00:12:35 -0700
Subject: [PATCH] [LoopFuse] Don't preserve SCEV analysis

This patch fixes issue while verifying SCEV.
As the loops are fused, SCEV information is not valid
and rather then recomputing it in the pass,
we should prefer to let pass manager recompute it for
us when next pass requests it.

When there is no fusion, all analyses are preserved.
---
 llvm/lib/Transforms/Scalar/LoopFuse.cpp | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/llvm/lib/Transforms/Scalar/LoopFuse.cpp b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
index b5eb647a042b9..34d3abe0429ab 100644
--- a/llvm/lib/Transforms/Scalar/LoopFuse.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
@@ -639,7 +639,6 @@ struct LoopFuser {
     assert(DT.verify());
     assert(PDT.verify());
     LI.verify(DT);
-    SE.verify();
 #endif
 
     LLVM_DEBUG(dbgs() << "Loop Fusion complete\n");
@@ -1786,7 +1785,6 @@ struct LoopFuser {
     assert(DT.verify(DominatorTree::VerificationLevel::Fast));
     assert(PDT.verify());
     LI.verify(DT);
-    SE.verify();
 #endif
 
     LLVM_DEBUG(dbgs() << "Fusion done:\n");
@@ -2082,7 +2080,6 @@ struct LoopFuser {
     assert(DT.verify(DominatorTree::VerificationLevel::Fast));
     assert(PDT.verify());
     LI.verify(DT);
-    SE.verify();
 #endif
 
     LLVM_DEBUG(dbgs() << "Fusion done:\n");
@@ -2122,7 +2119,6 @@ PreservedAnalyses LoopFusePass::run(Function &F, FunctionAnalysisManager &AM) {
   PreservedAnalyses PA;
   PA.preserve<DominatorTreeAnalysis>();
   PA.preserve<PostDominatorTreeAnalysis>();
-  PA.preserve<ScalarEvolutionAnalysis>();
   PA.preserve<LoopAnalysis>();
   return PA;
 }



More information about the llvm-commits mailing list