650b4af139e23c4c10c84c1e1e51e881f122cd56
[oota-llvm.git] / test / Other / constant-fold-gep.ll
1 ; "PLAIN" - No optimizations. This tests the target-independent
2 ; constant folder.
3 ; RUN: opt -S -o - < %s | FileCheck --check-prefix=PLAIN %s
4
5 ; "OPT" - Optimizations but no targetdata. This tests target-independent
6 ; folding in the optimizers.
7 ; RUN: opt -S -o - -instcombine -globalopt < %s | FileCheck --check-prefix=OPT %s
8
9 ; "TO" - Optimizations and targetdata. This tests target-dependent
10 ; folding in the optimizers.
11 ; RUN: opt -S -o - -instcombine -globalopt -default-data-layout="e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" < %s | FileCheck --check-prefix=TO %s
12
13 ; "SCEV" - ScalarEvolution but no targetdata.
14 ; RUN: opt -analyze -scalar-evolution < %s | FileCheck --check-prefix=SCEV %s
15
16 ; ScalarEvolution with targetdata isn't interesting on these testcases
17 ; because ScalarEvolution doesn't attempt to duplicate all of instcombine's
18 ; and the constant folders' folding.
19
20 ; PLAIN: %0 = type { i1, double }
21 ; PLAIN: %1 = type { double, float, double, double }
22 ; PLAIN: %2 = type { i1, i1* }
23 ; PLAIN: %3 = type { i64, i64 }
24 ; OPT: %0 = type { i1, double }
25 ; OPT: %1 = type { double, float, double, double }
26 ; OPT: %2 = type { i1, i1* }
27 ; OPT: %3 = type { i64, i64 }
28
29 ; The automatic constant folder in opt does not have targetdata access, so
30 ; it can't fold gep arithmetic, in general. However, the constant folder run
31 ; from instcombine and global opt can use targetdata.
32
33 ; PLAIN: @G8 = global i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -1)
34 ; PLAIN: @G1 = global i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -1)
35 ; PLAIN: @F8 = global i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -2)
36 ; PLAIN: @F1 = global i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -2)
37 ; PLAIN: @H8 = global i8* getelementptr (i8* null, i32 -1)
38 ; PLAIN: @H1 = global i1* getelementptr (i1* null, i32 -1)
39 ; OPT: @G8 = global i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -1)
40 ; OPT: @G1 = global i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -1)
41 ; OPT: @F8 = global i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -2)
42 ; OPT: @F1 = global i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -2)
43 ; OPT: @H8 = global i8* getelementptr (i8* null, i32 -1)
44 ; OPT: @H1 = global i1* getelementptr (i1* null, i32 -1)
45 ; TO: @G8 = global i8* null
46 ; TO: @G1 = global i1* null
47 ; TO: @F8 = global i8* inttoptr (i64 -1 to i8*)
48 ; TO: @F1 = global i1* inttoptr (i64 -1 to i1*)
49 ; TO: @H8 = global i8* inttoptr (i64 -1 to i8*)
50 ; TO: @H1 = global i1* inttoptr (i64 -1 to i1*)
51
52 @G8 = global i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -1)
53 @G1 = global i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -1)
54 @F8 = global i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -2)
55 @F1 = global i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -2)
56 @H8 = global i8* getelementptr (i8* inttoptr (i32 0 to i8*), i32 -1)
57 @H1 = global i1* getelementptr (i1* inttoptr (i32 0 to i1*), i32 -1)
58
59 ; The target-independent folder should be able to do some clever
60 ; simplifications on sizeof, alignof, and offsetof expressions. The
61 ; target-dependent folder should fold these down to constants.
62
63 ; PLAIN: @a = constant i64 mul (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 2310)
64 ; PLAIN: @b = constant i64 ptrtoint (double* getelementptr (%0* null, i64 0, i32 1) to i64)
65 ; PLAIN: @c = constant i64 mul nuw (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 2)
66 ; PLAIN: @d = constant i64 mul nuw (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 11)
67 ; PLAIN: @e = constant i64 ptrtoint (double* getelementptr (%1* null, i64 0, i32 2) to i64)
68 ; PLAIN: @f = constant i64 1
69 ; PLAIN: @g = constant i64 ptrtoint (double* getelementptr (%0* null, i64 0, i32 1) to i64)
70 ; PLAIN: @h = constant i64 ptrtoint (i1** getelementptr (i1** null, i32 1) to i64)
71 ; PLAIN: @i = constant i64 ptrtoint (i1** getelementptr (%2* null, i64 0, i32 1) to i64)
72 ; PLAIN: @j = constant i64 ptrtoint (double* getelementptr (%0* null, i64 0, i32 1) to i64)
73 ; PLAIN: @k = constant i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64)
74 ; OPT: @a = constant i64 mul (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 2310)
75 ; OPT: @b = constant i64 ptrtoint (double* getelementptr (%0* null, i64 0, i32 1) to i64)
76 ; OPT: @c = constant i64 mul (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 2)
77 ; OPT: @d = constant i64 mul (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 11)
78 ; OPT: @e = constant i64 ptrtoint (double* getelementptr (%1* null, i64 0, i32 2) to i64)
79 ; OPT: @f = constant i64 1
80 ; OPT: @g = constant i64 ptrtoint (double* getelementptr (%0* null, i64 0, i32 1) to i64)
81 ; OPT: @h = constant i64 ptrtoint (i1** getelementptr (i1** null, i32 1) to i64)
82 ; OPT: @i = constant i64 ptrtoint (i1** getelementptr (%2* null, i64 0, i32 1) to i64)
83 ; OPT: @j = constant i64 ptrtoint (double* getelementptr (%0* null, i64 0, i32 1) to i64)
84 ; OPT: @k = constant i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64)
85 ; TO: @a = constant i64 18480
86 ; TO: @b = constant i64 8
87 ; TO: @c = constant i64 16
88 ; TO: @d = constant i64 88
89 ; TO: @e = constant i64 16
90 ; TO: @f = constant i64 1
91 ; TO: @g = constant i64 8
92 ; TO: @h = constant i64 8
93 ; TO: @i = constant i64 8
94 ; TO: @j = constant i64 8
95 ; TO: @k = constant i64 8
96
97 @a = constant i64 mul (i64 3, i64 mul (i64 ptrtoint ({[7 x double], [7 x double]}* getelementptr ({[7 x double], [7 x double]}* null, i64 11) to i64), i64 5))
98 @b = constant i64 ptrtoint ([13 x double]* getelementptr ({i1, [13 x double]}* null, i64 0, i32 1) to i64)
99 @c = constant i64 ptrtoint (double* getelementptr ({double, double, double, double}* null, i64 0, i32 2) to i64)
100 @d = constant i64 ptrtoint (double* getelementptr ([13 x double]* null, i64 0, i32 11) to i64)
101 @e = constant i64 ptrtoint (double* getelementptr ({double, float, double, double}* null, i64 0, i32 2) to i64)
102 @f = constant i64 ptrtoint (<{ i16, i128 }>* getelementptr ({i1, <{ i16, i128 }>}* null, i64 0, i32 1) to i64)
103 @g = constant i64 ptrtoint ({double, double}* getelementptr ({i1, {double, double}}* null, i64 0, i32 1) to i64)
104 @h = constant i64 ptrtoint (double** getelementptr (double** null, i64 1) to i64)
105 @i = constant i64 ptrtoint (double** getelementptr ({i1, double*}* null, i64 0, i32 1) to i64)
106 @j = constant i64 ptrtoint (union {double, double}* getelementptr ({i1, union {double, double}}* null, i64 0, i32 1) to i64)
107 @k = constant i64 ptrtoint (union {double, double}* getelementptr (union {double, double}* null, i64 1) to i64)
108
109 ; The target-dependent folder should cast GEP indices to integer-sized pointers.
110
111 ; PLAIN: @M = constant i64* getelementptr (i64* null, i32 1)
112 ; PLAIN: @N = constant i64* getelementptr (%3* null, i32 0, i32 1)
113 ; PLAIN: @O = constant i64* getelementptr ([2 x i64]* null, i32 0, i32 1)
114 ; OPT: @M = constant i64* getelementptr (i64* null, i32 1)
115 ; OPT: @N = constant i64* getelementptr (%3* null, i32 0, i32 1)
116 ; OPT: @O = constant i64* getelementptr ([2 x i64]* null, i32 0, i32 1)
117 ; TO: @M = constant i64* inttoptr (i64 8 to i64*)
118 ; TO: @N = constant i64* inttoptr (i64 8 to i64*)
119 ; TO: @O = constant i64* inttoptr (i64 8 to i64*)
120
121 @M = constant i64* getelementptr (i64* null, i32 1)
122 @N = constant i64* getelementptr ({ i64, i64 }* null, i32 0, i32 1)
123 @O = constant i64* getelementptr ([2 x i64]* null, i32 0, i32 1)
124
125 ; Duplicate all of the above as function return values rather than
126 ; global initializers.
127
128 ; PLAIN: define i8* @goo8() nounwind {
129 ; PLAIN:   %t = bitcast i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -1) to i8*
130 ; PLAIN:   ret i8* %t
131 ; PLAIN: }
132 ; PLAIN: define i1* @goo1() nounwind {
133 ; PLAIN:   %t = bitcast i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -1) to i1*
134 ; PLAIN:   ret i1* %t
135 ; PLAIN: }
136 ; PLAIN: define i8* @foo8() nounwind {
137 ; PLAIN:   %t = bitcast i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -2) to i8*
138 ; PLAIN:   ret i8* %t
139 ; PLAIN: }
140 ; PLAIN: define i1* @foo1() nounwind {
141 ; PLAIN:   %t = bitcast i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -2) to i1*
142 ; PLAIN:   ret i1* %t
143 ; PLAIN: }
144 ; PLAIN: define i8* @hoo8() nounwind {
145 ; PLAIN:   %t = bitcast i8* getelementptr (i8* null, i32 -1) to i8*
146 ; PLAIN:   ret i8* %t
147 ; PLAIN: }
148 ; PLAIN: define i1* @hoo1() nounwind {
149 ; PLAIN:   %t = bitcast i1* getelementptr (i1* null, i32 -1) to i1*
150 ; PLAIN:   ret i1* %t
151 ; PLAIN: }
152 ; OPT: define i8* @goo8() nounwind {
153 ; OPT:   ret i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -1)
154 ; OPT: }
155 ; OPT: define i1* @goo1() nounwind {
156 ; OPT:   ret i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -1)
157 ; OPT: }
158 ; OPT: define i8* @foo8() nounwind {
159 ; OPT:   ret i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -2)
160 ; OPT: }
161 ; OPT: define i1* @foo1() nounwind {
162 ; OPT:   ret i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -2)
163 ; OPT: }
164 ; OPT: define i8* @hoo8() nounwind {
165 ; OPT:   ret i8* getelementptr (i8* null, i32 -1)
166 ; OPT: }
167 ; OPT: define i1* @hoo1() nounwind {
168 ; OPT:   ret i1* getelementptr (i1* null, i32 -1)
169 ; OPT: }
170 ; TO: define i8* @goo8() nounwind {
171 ; TO:   ret i8* null
172 ; TO: }
173 ; TO: define i1* @goo1() nounwind {
174 ; TO:   ret i1* null
175 ; TO: }
176 ; TO: define i8* @foo8() nounwind {
177 ; TO:   ret i8* inttoptr (i64 -1 to i8*)
178 ; TO: }
179 ; TO: define i1* @foo1() nounwind {
180 ; TO:   ret i1* inttoptr (i64 -1 to i1*)
181 ; TO: }
182 ; TO: define i8* @hoo8() nounwind {
183 ; TO:   ret i8* inttoptr (i64 -1 to i8*)
184 ; TO: }
185 ; TO: define i1* @hoo1() nounwind {
186 ; TO:   ret i1* inttoptr (i64 -1 to i1*)
187 ; TO: }
188 ; SCEV: Classifying expressions for: @goo8
189 ; SCEV:   %t = bitcast i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -1) to i8*
190 ; SCEV:   -->  ((-1 * sizeof(i8)) + inttoptr (i32 1 to i8*))
191 ; SCEV: Classifying expressions for: @goo1
192 ; SCEV:   %t = bitcast i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -1) to i1*
193 ; SCEV:   -->  ((-1 * sizeof(i1)) + inttoptr (i32 1 to i1*))
194 ; SCEV: Classifying expressions for: @foo8
195 ; SCEV:   %t = bitcast i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -2) to i8*
196 ; SCEV:   -->  ((-2 * sizeof(i8)) + inttoptr (i32 1 to i8*))
197 ; SCEV: Classifying expressions for: @foo1
198 ; SCEV:   %t = bitcast i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -2) to i1*
199 ; SCEV:   -->  ((-2 * sizeof(i1)) + inttoptr (i32 1 to i1*))
200 ; SCEV: Classifying expressions for: @hoo8
201 ; SCEV:   -->  (-1 * sizeof(i8))
202 ; SCEV: Classifying expressions for: @hoo1
203 ; SCEV:   -->  (-1 * sizeof(i1))
204
205 define i8* @goo8() nounwind {
206   %t = bitcast i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -1) to i8*
207   ret i8* %t
208 }
209 define i1* @goo1() nounwind {
210   %t = bitcast i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -1) to i1*
211   ret i1* %t
212 }
213 define i8* @foo8() nounwind {
214   %t = bitcast i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -2) to i8*
215   ret i8* %t
216 }
217 define i1* @foo1() nounwind {
218   %t = bitcast i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -2) to i1*
219   ret i1* %t
220 }
221 define i8* @hoo8() nounwind {
222   %t = bitcast i8* getelementptr (i8* inttoptr (i32 0 to i8*), i32 -1) to i8*
223   ret i8* %t
224 }
225 define i1* @hoo1() nounwind {
226   %t = bitcast i1* getelementptr (i1* inttoptr (i32 0 to i1*), i32 -1) to i1*
227   ret i1* %t
228 }
229
230 ; PLAIN: define i64 @fa() nounwind {
231 ; PLAIN:   %t = bitcast i64 mul (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 2310) to i64
232 ; PLAIN:   ret i64 %t
233 ; PLAIN: }
234 ; PLAIN: define i64 @fb() nounwind {
235 ; PLAIN:   %t = bitcast i64 ptrtoint (double* getelementptr (%0* null, i64 0, i32 1) to i64) to i64
236 ; PLAIN:   ret i64 %t
237 ; PLAIN: }
238 ; PLAIN: define i64 @fc() nounwind {
239 ; PLAIN:   %t = bitcast i64 mul nuw (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 2) to i64
240 ; PLAIN:   ret i64 %t
241 ; PLAIN: }
242 ; PLAIN: define i64 @fd() nounwind {
243 ; PLAIN:   %t = bitcast i64 mul nuw (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 11) to i64
244 ; PLAIN:   ret i64 %t
245 ; PLAIN: }
246 ; PLAIN: define i64 @fe() nounwind {
247 ; PLAIN:   %t = bitcast i64 ptrtoint (double* getelementptr (%1* null, i64 0, i32 2) to i64) to i64
248 ; PLAIN:   ret i64 %t
249 ; PLAIN: }
250 ; PLAIN: define i64 @ff() nounwind {
251 ; PLAIN:   %t = bitcast i64 1 to i64
252 ; PLAIN:   ret i64 %t
253 ; PLAIN: }
254 ; PLAIN: define i64 @fg() nounwind {
255 ; PLAIN:   %t = bitcast i64 ptrtoint (double* getelementptr (%0* null, i64 0, i32 1) to i64) to i64
256 ; PLAIN:   ret i64 %t
257 ; PLAIN: }
258 ; PLAIN: define i64 @fh() nounwind {
259 ; PLAIN:   %t = bitcast i64 ptrtoint (i1** getelementptr (i1** null, i32 1) to i64) to i64
260 ; PLAIN:   ret i64 %t
261 ; PLAIN: }
262 ; PLAIN: define i64 @fi() nounwind {
263 ; PLAIN:   %t = bitcast i64 ptrtoint (i1** getelementptr (%2* null, i64 0, i32 1) to i64) to i64
264 ; PLAIN:   ret i64 %t
265 ; PLAIN: }
266 ; PLAIN: define i64 @fj() nounwind {
267 ; PLAIN:   %t = bitcast i64 ptrtoint (double* getelementptr (%0* null, i64 0, i32 1) to i64) to i64
268 ; PLAIN:   ret i64 %t
269 ; PLAIN: }
270 ; PLAIN: define i64 @fk() nounwind {
271 ; PLAIN:   %t = bitcast i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64) to i64
272 ; PLAIN:   ret i64 %t
273 ; PLAIN: }
274 ; OPT: define i64 @fa() nounwind {
275 ; OPT:   ret i64 mul (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 2310)
276 ; OPT: }
277 ; OPT: define i64 @fb() nounwind {
278 ; OPT:   ret i64 ptrtoint (double* getelementptr (%0* null, i64 0, i32 1) to i64)
279 ; OPT: }
280 ; OPT: define i64 @fc() nounwind {
281 ; OPT:   ret i64 mul nuw (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 2)
282 ; OPT: }
283 ; OPT: define i64 @fd() nounwind {
284 ; OPT:   ret i64 mul nuw (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 11)
285 ; OPT: }
286 ; OPT: define i64 @fe() nounwind {
287 ; OPT:   ret i64 ptrtoint (double* getelementptr (%1* null, i64 0, i32 2) to i64)
288 ; OPT: }
289 ; OPT: define i64 @ff() nounwind {
290 ; OPT:   ret i64 1
291 ; OPT: }
292 ; OPT: define i64 @fg() nounwind {
293 ; OPT:   ret i64 ptrtoint (double* getelementptr (%0* null, i64 0, i32 1) to i64)
294 ; OPT: }
295 ; OPT: define i64 @fh() nounwind {
296 ; OPT:   ret i64 ptrtoint (i1** getelementptr (i1** null, i32 1) to i64)
297 ; OPT: }
298 ; OPT: define i64 @fi() nounwind {
299 ; OPT:   ret i64 ptrtoint (i1** getelementptr (%2* null, i64 0, i32 1) to i64)
300 ; OPT: }
301 ; OPT: define i64 @fj() nounwind {
302 ; OPT:   ret i64 ptrtoint (double* getelementptr (%0* null, i64 0, i32 1) to i64)
303 ; OPT: }
304 ; OPT: define i64 @fk() nounwind {
305 ; OPT:   ret i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64)
306 ; OPT: }
307 ; TO: define i64 @fa() nounwind {
308 ; TO:   ret i64 18480
309 ; TO: }
310 ; TO: define i64 @fb() nounwind {
311 ; TO:   ret i64 8
312 ; TO: }
313 ; TO: define i64 @fc() nounwind {
314 ; TO:   ret i64 16
315 ; TO: }
316 ; TO: define i64 @fd() nounwind {
317 ; TO:   ret i64 88
318 ; TO: }
319 ; TO: define i64 @fe() nounwind {
320 ; TO:   ret i64 16
321 ; TO: }
322 ; TO: define i64 @ff() nounwind {
323 ; TO:   ret i64 1
324 ; TO: }
325 ; TO: define i64 @fg() nounwind {
326 ; TO:   ret i64 8
327 ; TO: }
328 ; TO: define i64 @fh() nounwind {
329 ; TO:   ret i64 8
330 ; TO: }
331 ; TO: define i64 @fi() nounwind {
332 ; TO:   ret i64 8
333 ; TO: }
334 ; TO: define i64 @fj() nounwind {
335 ; TO:   ret i64 8
336 ; TO: }
337 ; TO: define i64 @fk() nounwind {
338 ; TO:   ret i64 8
339 ; TO: }
340 ; SCEV: Classifying expressions for: @fa
341 ; SCEV:   %t = bitcast i64 mul (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 2310) to i64 
342 ; SCEV:   -->  (2310 * sizeof(double))
343 ; SCEV: Classifying expressions for: @fb
344 ; SCEV:   %t = bitcast i64 ptrtoint (double* getelementptr (%0* null, i64 0, i32 1) to i64) to i64 
345 ; SCEV:   -->  alignof(double)
346 ; SCEV: Classifying expressions for: @fc
347 ; SCEV:   %t = bitcast i64 mul nuw (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 2) to i64 
348 ; SCEV:   -->  (2 * sizeof(double))
349 ; SCEV: Classifying expressions for: @fd
350 ; SCEV:   %t = bitcast i64 mul nuw (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 11) to i64 
351 ; SCEV:   -->  (11 * sizeof(double))
352 ; SCEV: Classifying expressions for: @fe
353 ; SCEV:   %t = bitcast i64 ptrtoint (double* getelementptr (%1* null, i64 0, i32 2) to i64) to i64 
354 ; SCEV:   -->  offsetof({ double, float, double, double }, 2)
355 ; SCEV: Classifying expressions for: @ff
356 ; SCEV:   %t = bitcast i64 1 to i64 
357 ; SCEV:   -->  1
358 ; SCEV: Classifying expressions for: @fg
359 ; SCEV:   %t = bitcast i64 ptrtoint (double* getelementptr (%0* null, i64 0, i32 1) to i64) to i64
360 ; SCEV:   -->  alignof(double)
361 ; SCEV: Classifying expressions for: @fh
362 ; SCEV:   %t = bitcast i64 ptrtoint (i1** getelementptr (i1** null, i32 1) to i64) to i64
363 ; SCEV:   -->  sizeof(i1*)
364 ; SCEV: Classifying expressions for: @fi
365 ; SCEV:   %t = bitcast i64 ptrtoint (i1** getelementptr (%2* null, i64 0, i32 1) to i64) to i64
366 ; SCEV:   -->  alignof(i1*)
367 ; SCEV: Classifying expressions for: @fj
368 ; SCEV:   %t = bitcast i64 ptrtoint (double* getelementptr (%0* null, i64 0, i32 1) to i64) to i64
369 ; SCEV:   -->  alignof(double)
370 ; SCEV: Classifying expressions for: @fk
371 ; SCEV:   %t = bitcast i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64) to i64
372 ; SCEV:   -->  sizeof(double)
373
374 define i64 @fa() nounwind {
375   %t = bitcast i64 mul (i64 3, i64 mul (i64 ptrtoint ({[7 x double], [7 x double]}* getelementptr ({[7 x double], [7 x double]}* null, i64 11) to i64), i64 5)) to i64
376   ret i64 %t
377 }
378 define i64 @fb() nounwind {
379   %t = bitcast i64 ptrtoint ([13 x double]* getelementptr ({i1, [13 x double]}* null, i64 0, i32 1) to i64) to i64
380   ret i64 %t
381 }
382 define i64 @fc() nounwind {
383   %t = bitcast i64 ptrtoint (double* getelementptr ({double, double, double, double}* null, i64 0, i32 2) to i64) to i64
384   ret i64 %t
385 }
386 define i64 @fd() nounwind {
387   %t = bitcast i64 ptrtoint (double* getelementptr ([13 x double]* null, i64 0, i32 11) to i64) to i64
388   ret i64 %t
389 }
390 define i64 @fe() nounwind {
391   %t = bitcast i64 ptrtoint (double* getelementptr ({double, float, double, double}* null, i64 0, i32 2) to i64) to i64
392   ret i64 %t
393 }
394 define i64 @ff() nounwind {
395   %t = bitcast i64 ptrtoint (<{ i16, i128 }>* getelementptr ({i1, <{ i16, i128 }>}* null, i64 0, i32 1) to i64) to i64
396   ret i64 %t
397 }
398 define i64 @fg() nounwind {
399   %t = bitcast i64 ptrtoint ({double, double}* getelementptr ({i1, {double, double}}* null, i64 0, i32 1) to i64) to i64
400   ret i64 %t
401 }
402 define i64 @fh() nounwind {
403   %t = bitcast i64 ptrtoint (double** getelementptr (double** null, i32 1) to i64) to i64
404   ret i64 %t
405 }
406 define i64 @fi() nounwind {
407   %t = bitcast i64 ptrtoint (double** getelementptr ({i1, double*}* null, i64 0, i32 1) to i64) to i64
408   ret i64 %t
409 }
410 define i64 @fj() nounwind {
411   %t = bitcast i64 ptrtoint (union {double, double}* getelementptr ({i1, union {double, double}}* null, i64 0, i32 1) to i64) to i64
412   ret i64 %t
413 }
414 define i64 @fk() nounwind {
415   %t = bitcast i64 ptrtoint (union {double, double}* getelementptr (union {double, double}* null, i64 1) to i64) to i64
416   ret i64 %t
417 }
418
419 ; PLAIN: define i64* @fM() nounwind {
420 ; PLAIN:   %t = bitcast i64* getelementptr (i64* null, i32 1) to i64*
421 ; PLAIN:   ret i64* %t
422 ; PLAIN: }
423 ; PLAIN: define i64* @fN() nounwind {
424 ; PLAIN:   %t = bitcast i64* getelementptr (%3* null, i32 0, i32 1) to i64*
425 ; PLAIN:   ret i64* %t
426 ; PLAIN: }
427 ; PLAIN: define i64* @fO() nounwind {
428 ; PLAIN:   %t = bitcast i64* getelementptr ([2 x i64]* null, i32 0, i32 1) to i64*
429 ; PLAIN:   ret i64* %t
430 ; PLAIN: }
431 ; OPT: define i64* @fM() nounwind {
432 ; OPT:   ret i64* getelementptr (i64* null, i32 1)
433 ; OPT: }
434 ; OPT: define i64* @fN() nounwind {
435 ; OPT:   ret i64* getelementptr (%3* null, i32 0, i32 1)
436 ; OPT: }
437 ; OPT: define i64* @fO() nounwind {
438 ; OPT:   ret i64* getelementptr ([2 x i64]* null, i32 0, i32 1)
439 ; OPT: }
440 ; TO: define i64* @fM() nounwind {
441 ; TO:   ret i64* inttoptr (i64 8 to i64*)
442 ; TO: }
443 ; TO: define i64* @fN() nounwind {
444 ; TO:   ret i64* inttoptr (i64 8 to i64*)
445 ; TO: }
446 ; TO: define i64* @fO() nounwind {
447 ; TO:   ret i64* inttoptr (i64 8 to i64*)
448 ; TO: }
449 ; SCEV: Classifying expressions for: @fM
450 ; SCEV:   %t = bitcast i64* getelementptr (i64* null, i32 1) to i64* 
451 ; SCEV:   -->  sizeof(i64)
452 ; SCEV: Classifying expressions for: @fN
453 ; SCEV:   %t = bitcast i64* getelementptr (%3* null, i32 0, i32 1) to i64* 
454 ; SCEV:   -->  sizeof(i64)
455 ; SCEV: Classifying expressions for: @fO
456 ; SCEV:   %t = bitcast i64* getelementptr ([2 x i64]* null, i32 0, i32 1) to i64* 
457 ; SCEV:   -->  sizeof(i64)
458
459 define i64* @fM() nounwind {
460   %t = bitcast i64* getelementptr (i64* null, i32 1) to i64*
461   ret i64* %t
462 }
463 define i64* @fN() nounwind {
464   %t = bitcast i64* getelementptr ({ i64, i64 }* null, i32 0, i32 1) to i64*
465   ret i64* %t
466 }
467 define i64* @fO() nounwind {
468   %t = bitcast i64* getelementptr ([2 x i64]* null, i32 0, i32 1) to i64*
469   ret i64* %t
470 }