[PATCH] D152053: [InlineCost]Account for switch instructons when the switch condition could besimplified as a result of inlines.
Mingming Liu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 2 21:36:20 PDT 2023
mingmingl created this revision.
Herald added subscribers: ChuanqiXu, haicheng, hiraditya.
Herald added a project: All.
mingmingl requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D152053
Files:
llvm/lib/Analysis/InlineCost.cpp
Index: llvm/lib/Analysis/InlineCost.cpp
===================================================================
--- llvm/lib/Analysis/InlineCost.cpp
+++ llvm/lib/Analysis/InlineCost.cpp
@@ -853,6 +853,10 @@
SimplifiedValues.lookup(BI->getCondition()))) {
CurrentSavings += InstrCost;
}
+ } else if (SwitchInst *SI = dyn_cast<SwitchInst>(&I)) {
+ if (Value *V = SimplifiedValues.lookup(SI->getCondition()) &&
+ isa<ConstantInt>(V))
+ CurrentSavings += InstrCost;
} else if (Value *V = dyn_cast<Value>(&I)) {
// Count an instruction as savings if we can fold it.
if (SimplifiedValues.count(V)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152053.528071.patch
Type: text/x-patch
Size: 715 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230603/9111a20c/attachment.bin>
More information about the llvm-commits
mailing list