OSDN Git Service

am 008f5bfe: am ce9904c6: Merge remote-tracking branch \'upstream/release_34\' into...
[android-x86/external-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 {{.*}} zext
42   %A1 = zext <16 x i8> undef to <16 x i16>
43   ;CHECK: cost of 1 {{.*}} sext
44   %A2 = sext <16 x i8> undef to <16 x i16>
45   ;CHECK: cost of 1 {{.*}} sext
46   %A = sext <8 x i16> undef to <8 x i32>
47   ;CHECK: cost of 1 {{.*}} zext
48   %B = zext <8 x i16> undef to <8 x i32>
49   ;CHECK: cost of 1 {{.*}} sext
50   %C = sext <4 x i32> undef to <4 x i64>
51   ;CHECK: cost of 6 {{.*}} sext
52   %C1 = sext <4 x i8> undef to <4 x i64>
53   ;CHECK: cost of 6 {{.*}} sext
54   %C2 = sext <4 x i16> undef to <4 x i64>
55
56   ;CHECK: cost of 1 {{.*}} zext
57   %D = zext <4 x i32> undef to <4 x i64>
58
59   ;CHECK: cost of 1 {{.*}} trunc
60   %E = trunc <4 x i64> undef to <4 x i32>
61   ;CHECK: cost of 1 {{.*}} trunc
62   %F = trunc <8 x i32> undef to <8 x i16>
63   ;CHECK: cost of 2 {{.*}} trunc
64   %F1 = trunc <16 x i16> undef to <16 x i8>
65
66   ;CHECK: cost of 3 {{.*}} trunc
67   %G = trunc <8 x i64> undef to <8 x i32>
68
69   ret i32 undef
70 }
71
72 define i32 @masks8(<8 x i1> %in) {
73   ;CHECK: cost of 6 {{.*}} zext
74   %Z = zext <8 x i1> %in to <8 x i32>
75   ;CHECK: cost of 9 {{.*}} sext
76   %S = sext <8 x i1> %in to <8 x i32>
77   ret i32 undef
78 }
79
80 define i32 @masks4(<4 x i1> %in) {
81   ;CHECK: cost of 8 {{.*}} sext
82   %S = sext <4 x i1> %in to <4 x i64>
83   ret i32 undef
84 }
85
86 define void @sitofp4(<4 x i1> %a, <4 x i8> %b, <4 x i16> %c, <4 x i32> %d) {
87   ; CHECK: cost of 3 {{.*}} sitofp
88   %A1 = sitofp <4 x i1> %a to <4 x float>
89   ; CHECK: cost of 3 {{.*}} sitofp
90   %A2 = sitofp <4 x i1> %a to <4 x double>
91
92   ; CHECK: cost of 3 {{.*}} sitofp
93   %B1 = sitofp <4 x i8> %b to <4 x float>
94   ; CHECK: cost of 3 {{.*}} sitofp
95   %B2 = sitofp <4 x i8> %b to <4 x double>
96
97   ; CHECK: cost of 3 {{.*}} sitofp
98   %C1 = sitofp <4 x i16> %c to <4 x float>
99   ; CHECK: cost of 3 {{.*}} sitofp
100   %C2 = sitofp <4 x i16> %c to <4 x double>
101
102   ; CHECK: cost of 1 {{.*}} sitofp
103   %D1 = sitofp <4 x i32> %d to <4 x float>
104   ; CHECK: cost of 1 {{.*}} sitofp
105   %D2 = sitofp <4 x i32> %d to <4 x double>
106   ret void
107 }
108
109 define void @sitofp8(<8 x i1> %a, <8 x i8> %b, <8 x i16> %c, <8 x i32> %d) {
110   ; CHECK: cost of 8 {{.*}} sitofp
111   %A1 = sitofp <8 x i1> %a to <8 x float>
112
113   ; CHECK: cost of 8 {{.*}} sitofp
114   %B1 = sitofp <8 x i8> %b to <8 x float>
115
116   ; CHECK: cost of 5 {{.*}} sitofp
117   %C1 = sitofp <8 x i16> %c to <8 x float>
118
119   ; CHECK: cost of 1 {{.*}} sitofp
120   %D1 = sitofp <8 x i32> %d to <8 x float>
121   ret void
122 }
123
124 define void @uitofp4(<4 x i1> %a, <4 x i8> %b, <4 x i16> %c, <4 x i32> %d) {
125   ; CHECK: cost of 7 {{.*}} uitofp
126   %A1 = uitofp <4 x i1> %a to <4 x float>
127   ; CHECK: cost of 7 {{.*}} uitofp
128   %A2 = uitofp <4 x i1> %a to <4 x double>
129
130   ; CHECK: cost of 2 {{.*}} uitofp
131   %B1 = uitofp <4 x i8> %b to <4 x float>
132   ; CHECK: cost of 2 {{.*}} uitofp
133   %B2 = uitofp <4 x i8> %b to <4 x double>
134
135   ; CHECK: cost of 2 {{.*}} uitofp
136   %C1 = uitofp <4 x i16> %c to <4 x float>
137   ; CHECK: cost of 2 {{.*}} uitofp
138   %C2 = uitofp <4 x i16> %c to <4 x double>
139
140   ; CHECK: cost of 6 {{.*}} uitofp
141   %D1 = uitofp <4 x i32> %d to <4 x float>
142   ; CHECK: cost of 6 {{.*}} uitofp
143   %D2 = uitofp <4 x i32> %d to <4 x double>
144   ret void
145 }
146
147 define void @uitofp8(<8 x i1> %a, <8 x i8> %b, <8 x i16> %c, <8 x i32> %d) {
148   ; CHECK: cost of 6 {{.*}} uitofp
149   %A1 = uitofp <8 x i1> %a to <8 x float>
150
151   ; CHECK: cost of 5 {{.*}} uitofp
152   %B1 = uitofp <8 x i8> %b to <8 x float>
153
154   ; CHECK: cost of 5 {{.*}} uitofp
155   %C1 = uitofp <8 x i16> %c to <8 x float>
156
157   ; CHECK: cost of 9 {{.*}} uitofp
158   %D1 = uitofp <8 x i32> %d to <8 x float>
159   ret void
160 }