Cost Model: change the default cost of control flow instructions (br / ret / ......
[oota-llvm.git] / test / Analysis / CostModel / X86 / cast.ll
1 ; RUN: opt < %s  -cost-model -analyze -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx | FileCheck %s
2
3 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"
4 target triple = "x86_64-apple-macosx10.8.0"
5
6 define i32 @add(i32 %arg) {
7
8   ; -- Same size registeres --
9   ;CHECK: cost of 1 {{.*}} zext
10   %A = zext <4 x i1> undef to <4 x i32>
11   ;CHECK: cost of 2 {{.*}} sext
12   %B = sext <4 x i1> undef to <4 x i32>
13   ;CHECK: cost of 0 {{.*}} trunc
14   %C = trunc <4 x i32> undef to <4 x i1>
15
16   ; -- Different size registers --
17   ;CHECK-NOT: cost of 1 {{.*}} zext
18   %D = zext <8 x i1> undef to <8 x i32>
19   ;CHECK-NOT: cost of 2 {{.*}} sext
20   %E = sext <8 x i1> undef to <8 x i32>
21   ;CHECK-NOT: cost of 2 {{.*}} trunc
22   %F = trunc <8 x i32> undef to <8 x i1>
23
24   ; -- scalars --
25
26   ;CHECK: cost of 1 {{.*}} zext
27   %G = zext i1 undef to i32
28   ;CHECK: cost of 0 {{.*}} trunc
29   %H = trunc i32 undef to i1
30
31   ;CHECK: cost of 0 {{.*}} ret
32   ret i32 undef
33 }
34
35 define i32 @zext_sext(<8 x i1> %in) {
36   ;CHECK: cost of 6 {{.*}} zext
37   %Z = zext <8 x i1> %in to <8 x i32>
38   ;CHECK: cost of 9 {{.*}} sext
39   %S = sext <8 x i1> %in to <8 x i32>
40
41   ;CHECK: cost of 1 {{.*}} sext
42   %A = sext <8 x i16> undef to <8 x i32>
43   ;CHECK: cost of 1 {{.*}} zext
44   %B = zext <8 x i16> undef to <8 x i32>
45   ;CHECK: cost of 1 {{.*}} sext
46   %C = sext <4 x i32> undef to <4 x i64>
47
48   ;CHECK: cost of 1 {{.*}} zext
49   %D = zext <4 x i32> undef to <4 x i64>
50   ;CHECK: cost of 1 {{.*}} trunc
51
52   %E = trunc <4 x i64> undef to <4 x i32>
53   ;CHECK: cost of 1 {{.*}} trunc
54   %F = trunc <8 x i32> undef to <8 x i16>
55
56   ;CHECK: cost of 3 {{.*}} trunc
57   %G = trunc <8 x i64> undef to <8 x i32>
58
59   ret i32 undef
60 }
61
62 define i32 @masks(<8 x i1> %in) {
63   ;CHECK: cost of 6 {{.*}} zext
64   %Z = zext <8 x i1> %in to <8 x i32>
65   ;CHECK: cost of 9 {{.*}} sext
66   %S = sext <8 x i1> %in to <8 x i32>
67   ret i32 undef
68 }
69