[llvm] f0a787b - [DFAJumpThreading] Set MadeChanges only if threading happened (#162241)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 7 03:34:08 PDT 2025


Author: Hongyu Chen
Date: 2025-10-07T10:34:03Z
New Revision: f0a787b55df03e2b72e1d24b52e903714a0c0e7d

URL: https://github.com/llvm/llvm-project/commit/f0a787b55df03e2b72e1d24b52e903714a0c0e7d
DIFF: https://github.com/llvm/llvm-project/commit/f0a787b55df03e2b72e1d24b52e903714a0c0e7d.diff

LOG: [DFAJumpThreading] Set MadeChanges only if threading happened (#162241)

Threading may fail due to legality and profitability checks. This patch
preserves the analysis if no threading happens.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
index 7968a5d71fdff..3b75475a5277e 100644
--- a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
@@ -820,11 +820,13 @@ struct TransformDFA {
       : SwitchPaths(SwitchPaths), DT(DT), AC(AC), TTI(TTI), ORE(ORE),
         EphValues(EphValues) {}
 
-  void run() {
+  bool run() {
     if (isLegalAndProfitableToTransform()) {
       createAllExitPaths();
       NumTransforms++;
+      return true;
     }
+    return false;
   }
 
 private:
@@ -1426,9 +1428,8 @@ bool DFAJumpThreading::run(Function &F) {
 
   for (AllSwitchPaths SwitchPaths : ThreadableLoops) {
     TransformDFA Transform(&SwitchPaths, DT, AC, TTI, ORE, EphValues);
-    Transform.run();
-    MadeChanges = true;
-    LoopInfoBroken = true;
+    if (Transform.run())
+      MadeChanges = LoopInfoBroken = true;
   }
 
 #ifdef EXPENSIVE_CHECKS


        


More information about the llvm-commits mailing list