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

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 10 01:47:48 PST 2015


Author: hans
Date: Tue Nov 10 03:47:48 2015
New Revision: 252595

URL: http://llvm.org/viewvc/llvm-project?rev=252595&view=rev
Log:
Inliner: Do zero-cost inlines even if above a negative threshold (PR24851)

Differential Revision: http://reviews.llvm.org/D14499

Added:
    llvm/trunk/test/Transforms/Inline/zero-cost.ll
Modified:
    llvm/trunk/lib/Analysis/InlineCost.cpp

Modified: llvm/trunk/lib/Analysis/InlineCost.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=252595&r1=252594&r2=252595&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InlineCost.cpp (original)
+++ llvm/trunk/lib/Analysis/InlineCost.cpp Tue Nov 10 03:47:48 2015
@@ -1296,7 +1296,7 @@ bool CallAnalyzer::analyzeCall(CallSite
   else if (NumVectorInstructions <= NumInstructions / 2)
     Threshold -= (FiftyPercentVectorBonus - TenPercentVectorBonus);
 
-  return Cost < Threshold;
+  return Cost <= std::max(0, Threshold);
 }
 
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

Added: llvm/trunk/test/Transforms/Inline/zero-cost.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/zero-cost.ll?rev=252595&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/Inline/zero-cost.ll (added)
+++ llvm/trunk/test/Transforms/Inline/zero-cost.ll Tue Nov 10 03:47:48 2015
@@ -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
+}
+




More information about the llvm-commits mailing list