[PATCH] D144838: [SCCP] Correct the made changes behavior
chenglin.bi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 26 20:20:53 PST 2023
bcl5980 created this revision.
bcl5980 added reviewers: nikic, fhahn, chill.
Herald added subscribers: snehasish, ormris, StephenFan, hiraditya.
Herald added a project: All.
bcl5980 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
For now in some code path, even if it can be removed we still set `MadeChanges` to true. This patch fix them to make sure the `MadeChanges` set to true only if it is really changed.
https://reviews.llvm.org/D144838
Files:
llvm/lib/Transforms/IPO/SCCP.cpp
llvm/lib/Transforms/Utils/SCCPSolver.cpp
Index: llvm/lib/Transforms/Utils/SCCPSolver.cpp
===================================================================
--- llvm/lib/Transforms/Utils/SCCPSolver.cpp
+++ llvm/lib/Transforms/Utils/SCCPSolver.cpp
@@ -235,10 +235,8 @@
for (Instruction &Inst : make_early_inc_range(BB)) {
if (Inst.getType()->isVoidTy())
continue;
- if (tryToReplaceWithConstant(&Inst)) {
- if (canRemoveInstruction(&Inst))
- Inst.eraseFromParent();
-
+ if (tryToReplaceWithConstant(&Inst) && canRemoveInstruction(&Inst)) {
+ Inst.eraseFromParent();
MadeChanges = true;
++InstRemovedStat;
} else if (replaceSignedInst(*this, InsertedValues, Inst)) {
Index: llvm/lib/Transforms/IPO/SCCP.cpp
===================================================================
--- llvm/lib/Transforms/IPO/SCCP.cpp
+++ llvm/lib/Transforms/IPO/SCCP.cpp
@@ -212,10 +212,10 @@
LLVM_DEBUG(dbgs() << " BasicBlock Dead:" << BB);
++NumDeadBlocks;
- MadeChanges = true;
-
- if (&BB != &F.front())
+ if (&BB != &F.front()) {
+ MadeChanges = true;
BlocksToErase.push_back(&BB);
+ }
continue;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144838.500652.patch
Type: text/x-patch
Size: 1182 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230227/b4c06a2e/attachment.bin>
More information about the llvm-commits
mailing list