diff options
-rw-r--r-- | llvm/lib/Analysis/InlineCost.cpp | 2 | ||||
-rw-r--r-- | llvm/test/Transforms/Inline/zero-cost.ll | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index 8169ce48246..26f2e7ff504 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -1296,7 +1296,7 @@ bool CallAnalyzer::analyzeCall(CallSite CS) { else if (NumVectorInstructions <= NumInstructions / 2) Threshold -= (FiftyPercentVectorBonus - TenPercentVectorBonus); - return Cost < Threshold; + return Cost <= std::max(0, Threshold); } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) diff --git a/llvm/test/Transforms/Inline/zero-cost.ll b/llvm/test/Transforms/Inline/zero-cost.ll new file mode 100644 index 00000000000..8e7194a1963 --- /dev/null +++ b/llvm/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 +} + |