Index: llvm/trunk/lib/Analysis/InlineCost.cpp =================================================================== --- llvm/trunk/lib/Analysis/InlineCost.cpp +++ llvm/trunk/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) Index: llvm/trunk/test/Transforms/Inline/zero-cost.ll =================================================================== --- llvm/trunk/test/Transforms/Inline/zero-cost.ll +++ llvm/trunk/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 +} +