blob: 19e7128ff44932725d5c2e4fcd40e39eea0f1e38 [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 Weibce228c2017-09-22 18:25:53 +00008declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32)
9
Guozhi Wei62d64142017-09-08 22:29:17 +000010define i64 @foo(i64 %arg) {
11
Guozhi Wei3d1305f2017-09-15 22:28:12 +000012 ; LATENCY: cost of 0 {{.*}} alloca i32
13 ; CODESIZE: cost of 0 {{.*}} alloca i32
14 %A1 = alloca i32, align 8
15
16 ; LATENCY: cost of 1 {{.*}} alloca i64, i64 undef
17 ; CODESIZE: cost of 1 {{.*}} alloca i64, i64 undef
18 %A2 = alloca i64, i64 undef, align 8
19
Guozhi Wei62d64142017-09-08 22:29:17 +000020 ; LATENCY: cost of 1 {{.*}} %I64 = add
21 ; CODESIZE: cost of 1 {{.*}} %I64 = add
22 %I64 = add i64 undef, undef
23
24 ; LATENCY: cost of 4 {{.*}} load
25 ; CODESIZE: cost of 1 {{.*}} load
26 load i64, i64* undef, align 4
27
Guozhi Wei21f8fad2017-09-14 19:20:02 +000028 ; LATENCY: cost of 0 {{.*}} bitcast
29 ; CODESIZE: cost of 0 {{.*}} bitcast
30 %BC = bitcast i8* undef to i32*
31
32 ; LATENCY: cost of 0 {{.*}} inttoptr
33 ; CODESIZE: cost of 0 {{.*}} inttoptr
34 %I2P = inttoptr i64 undef to i8*
35
36 ; LATENCY: cost of 0 {{.*}} ptrtoint
37 ; CODESIZE: cost of 0 {{.*}} ptrtoint
38 %P2I = ptrtoint i8* undef to i64
39
40 ; LATENCY: cost of 0 {{.*}} trunc
41 ; CODESIZE: cost of 0 {{.*}} trunc
42 %TC = trunc i64 undef to i32
43
Guozhi Weibce228c2017-09-22 18:25:53 +000044 ; LATENCY: cost of 1 {{.*}} call
45 ; CODESIZE: cost of 1 {{.*}} call
46 %uadd = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 undef, i32 undef)
47
Guozhi Wei62d64142017-09-08 22:29:17 +000048 ; LATENCY: cost of 1 {{.*}} ret
49 ; CODESIZE: cost of 1 {{.*}} ret
50 ret i64 undef
51}