Guozhi Wei | 62d6414 | 2017-09-08 22:29:17 +0000 | [diff] [blame] | 1 | ; 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 Wei | 21f8fad | 2017-09-14 19:20:02 +0000 | [diff] [blame] | 6 | target 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 Wei | bce228c | 2017-09-22 18:25:53 +0000 | [diff] [blame^] | 8 | declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32) |
| 9 | |
Guozhi Wei | 62d6414 | 2017-09-08 22:29:17 +0000 | [diff] [blame] | 10 | define i64 @foo(i64 %arg) { |
| 11 | |
Guozhi Wei | 3d1305f | 2017-09-15 22:28:12 +0000 | [diff] [blame] | 12 | ; 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 Wei | 62d6414 | 2017-09-08 22:29:17 +0000 | [diff] [blame] | 20 | ; 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 Wei | 21f8fad | 2017-09-14 19:20:02 +0000 | [diff] [blame] | 28 | ; 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 Wei | bce228c | 2017-09-22 18:25:53 +0000 | [diff] [blame^] | 44 | ; 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 Wei | 62d6414 | 2017-09-08 22:29:17 +0000 | [diff] [blame] | 48 | ; LATENCY: cost of 1 {{.*}} ret |
| 49 | ; CODESIZE: cost of 1 {{.*}} ret |
| 50 | ret i64 undef |
| 51 | } |