[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
Wed Sep 20 14:10:08 PDT 2023


mingmingl updated this revision to Diff 557147.
mingmingl retitled this revision from "[InlineCost]Account for switch instructons when the switch condition could be
simplified as a result of inlines." to "[InlineCost]Account for switch instructons when the switch condition could besimplified as a result of inlines.".
mingmingl added a comment.

address feedback.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152053/new/

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
@@ -855,6 +855,9 @@
                   SimplifiedValues.lookup(BI->getCondition()))) {
             CurrentSavings += InstrCost;
           }
+        } else if (SwitchInst *SI = dyn_cast<SwitchInst>(&I)) {
+          if (isa_and_present<ConstantInt>(SimplifiedValues.lookup(SI->getCondition())))
+            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.557147.patch
Type: text/x-patch
Size: 684 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230920/fde747ac/attachment.bin>


More information about the llvm-commits mailing list