[llvm] [DFAJumpThreading] Set MadeChanges only if threading happened (PR #162241)
Hongyu Chen via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 7 02:55:59 PDT 2025
https://github.com/XChy updated https://github.com/llvm/llvm-project/pull/162241
>From 0cb12b65e43b53d0ac491ba26caf611e89b7ca78 Mon Sep 17 00:00:00 2001
From: XChy <xxs_chy at outlook.com>
Date: Tue, 7 Oct 2025 16:20:06 +0800
Subject: [PATCH 1/2] [DFAJumpThreading] Set MadeChanges only if threading
happened
---
llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
index 41a6c80943328..83def24eeaba6 100644
--- a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
@@ -820,11 +820,14 @@ struct TransformDFA {
: SwitchPaths(SwitchPaths), DT(DT), AC(AC), TTI(TTI), ORE(ORE),
EphValues(EphValues) {}
- void run() {
+ bool run() {
+ bool MadeChange = false;
if (isLegalAndProfitableToTransform()) {
createAllExitPaths();
+ MadeChange = true;
NumTransforms++;
}
+ return MadeChange;
}
private:
@@ -1426,9 +1429,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
>From bbdd8a932cf8be76bc378a7cfc35e4813163b27b Mon Sep 17 00:00:00 2001
From: XChy <xxs_chy at outlook.com>
Date: Tue, 7 Oct 2025 17:55:45 +0800
Subject: [PATCH 2/2] resolve comment
---
llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
index 83def24eeaba6..5204610a2a889 100644
--- a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
@@ -821,13 +821,12 @@ struct TransformDFA {
EphValues(EphValues) {}
bool run() {
- bool MadeChange = false;
if (isLegalAndProfitableToTransform()) {
createAllExitPaths();
- MadeChange = true;
NumTransforms++;
+ return true;
}
- return MadeChange;
+ return false;
}
private:
More information about the llvm-commits
mailing list