[PATCH] D14499: Inliner: Do zero-cost inlines even if above a negative threshold (PR24851)

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 9 07:49:25 PST 2015


hans created this revision.
hans added a reviewer: eraman.
hans added subscribers: llvm-commits, hansw.

Please take a look.

(See discussion at http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151102/310160.html)

http://reviews.llvm.org/D14499

Files:
  lib/Analysis/InlineCost.cpp
  test/Transforms/Inline/zero-cost.ll

Index: test/Transforms/Inline/zero-cost.ll
===================================================================
--- /dev/null
+++ test/Transforms/Inline/zero-cost.ll
@@ -0,0 +1,17 @@
+; RUN: opt -inline -S %s | FileCheck %s
+
+define void @f() {
+entry:
+  tail call void @g()
+  unreachable
+
+; CHECK-LABEL: @f
+; CHECK-NOT: call
+; CHECK: unreachable
+}
+
+define void @g() {
+entry:
+  unreachable
+}
+
Index: lib/Analysis/InlineCost.cpp
===================================================================
--- lib/Analysis/InlineCost.cpp
+++ lib/Analysis/InlineCost.cpp
@@ -1296,7 +1296,7 @@
   else if (NumVectorInstructions <= NumInstructions / 2)
     Threshold -= (FiftyPercentVectorBonus - TenPercentVectorBonus);
 
-  return Cost < Threshold;
+  return Cost <= std::max(0, Threshold);
 }
 
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14499.39692.patch
Type: text/x-patch
Size: 850 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151109/f9c1c78e/attachment.bin>


More information about the llvm-commits mailing list