Index: llvm/lib/Analysis/InlineCost.cpp =================================================================== --- llvm/lib/Analysis/InlineCost.cpp +++ llvm/lib/Analysis/InlineCost.cpp @@ -392,6 +392,12 @@ InlineResult analyze(); + Optional getSimplifiedValue(Instruction *I) { + if (SimplifiedValues.find(I) != SimplifiedValues.end()) + return SimplifiedValues[I]; + return None; + } + // Keep a bunch of stats about the cost savings found so we can print them // out when debugging. unsigned NumConstantArgs = 0; @@ -755,6 +761,11 @@ if (Record->hasThresholdChanged()) OS << ", threshold delta = " << Record->getThresholdDelta(); } + auto C = ICCA->getSimplifiedValue(const_cast(I)); + if (C) { + OS << ", simplified to "; + C.getValue()->print(OS, true); + } OS << "\n"; } Index: llvm/test/Transforms/Inline/simplified_to.ll =================================================================== --- /dev/null +++ llvm/test/Transforms/Inline/simplified_to.ll @@ -0,0 +1,15 @@ +; RUN: opt < %s -passes="print" 2>&1 | FileCheck %s + +; CHECK-LABEL: @test() +; CHECK: cost before = {{.*}}, cost after = {{.*}}, threshold before = {{.*}}, threshold after = {{.*}}, cost delta = {{.*}}, simplified to i1 false +; CHECK: %1 = icmp eq i32 4, 5 + +define i32 @test() { + %1 = icmp eq i32 4, 5 + ret i32 0 +} + +define void @main() { + %1 = call i32 @test() + ret void +}