576 changes: 14 additions & 562 deletions llvm/lib/Analysis/CostModel.cpp

Large diffs are not rendered by default.

557 changes: 557 additions & 0 deletions llvm/lib/Analysis/TargetTransformInfo.cpp

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions llvm/test/Analysis/CostModel/X86/costmodel.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; RUN: opt < %s -cost-model -cost-kind=latency -analyze -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 | FileCheck %s --check-prefix=LATENCY
; RUN: opt < %s -cost-model -cost-kind=code-size -analyze -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 | FileCheck %s --check-prefix=CODESIZE

; Tests if the interface TargetTransformInfo::getInstructionCost() works correctly.

define i64 @foo(i64 %arg) {

; LATENCY: cost of 1 {{.*}} %I64 = add
; CODESIZE: cost of 1 {{.*}} %I64 = add
%I64 = add i64 undef, undef

; LATENCY: cost of 4 {{.*}} load
; CODESIZE: cost of 1 {{.*}} load
load i64, i64* undef, align 4

; LATENCY: cost of 1 {{.*}} ret
; CODESIZE: cost of 1 {{.*}} ret
ret i64 undef
}