blob: d16cc27cb16e1ee52abe962db5496b982d87f415 [file] [log] [blame]
Guozhi Wei62d64142017-09-08 22:29:17 +00001; RUN: opt < %s -cost-model -cost-kind=latency -analyze -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 | FileCheck %s --check-prefix=LATENCY
2; RUN: opt < %s -cost-model -cost-kind=code-size -analyze -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 | FileCheck %s --check-prefix=CODESIZE
3
4; Tests if the interface TargetTransformInfo::getInstructionCost() works correctly.
5
Guozhi Wei21f8fad2017-09-14 19:20:02 +00006target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
7
Guozhi Wei62d64142017-09-08 22:29:17 +00008define i64 @foo(i64 %arg) {
9
Guozhi Wei3d1305f2017-09-15 22:28:12 +000010 ; LATENCY: cost of 0 {{.*}} alloca i32
11 ; CODESIZE: cost of 0 {{.*}} alloca i32
12 %A1 = alloca i32, align 8
13
14 ; LATENCY: cost of 1 {{.*}} alloca i64, i64 undef
15 ; CODESIZE: cost of 1 {{.*}} alloca i64, i64 undef
16 %A2 = alloca i64, i64 undef, align 8
17
Guozhi Wei62d64142017-09-08 22:29:17 +000018 ; LATENCY: cost of 1 {{.*}} %I64 = add
19 ; CODESIZE: cost of 1 {{.*}} %I64 = add
20 %I64 = add i64 undef, undef
21
22 ; LATENCY: cost of 4 {{.*}} load
23 ; CODESIZE: cost of 1 {{.*}} load
24 load i64, i64* undef, align 4
25
Guozhi Wei21f8fad2017-09-14 19:20:02 +000026 ; LATENCY: cost of 0 {{.*}} bitcast
27 ; CODESIZE: cost of 0 {{.*}} bitcast
28 %BC = bitcast i8* undef to i32*
29
30 ; LATENCY: cost of 0 {{.*}} inttoptr
31 ; CODESIZE: cost of 0 {{.*}} inttoptr
32 %I2P = inttoptr i64 undef to i8*
33
34 ; LATENCY: cost of 0 {{.*}} ptrtoint
35 ; CODESIZE: cost of 0 {{.*}} ptrtoint
36 %P2I = ptrtoint i8* undef to i64
37
38 ; LATENCY: cost of 0 {{.*}} trunc
39 ; CODESIZE: cost of 0 {{.*}} trunc
40 %TC = trunc i64 undef to i32
41
Guozhi Wei62d64142017-09-08 22:29:17 +000042 ; LATENCY: cost of 1 {{.*}} ret
43 ; CODESIZE: cost of 1 {{.*}} ret
44 ret i64 undef
45}