llvm.memory.barrier, and impl for x86 and alpha
[oota-llvm.git] / test / CodeGen / Generic / constindices.ll
1 ; RUN: llvm-upgrade %s | llvm-as | llc
2
3 ; Test that a sequence of constant indices are folded correctly
4 ; into the equivalent offset at compile-time.
5
6 %MixedA = type { float, [15 x int], sbyte, float }
7
8 %MixedB = type { float, %MixedA, float }
9
10 %fmtArg = internal global [44 x sbyte] c"sqrt(2) = %g\0Aexp(1) = %g\0Api = %g\0Afive = %g\0A\00"; <[44 x sbyte]*> [#uses=1]
11
12 implementation
13
14 declare int "printf"(sbyte*, ...)
15
16 int "main"()
17 begin
18         %ScalarA = alloca %MixedA
19         %ScalarB = alloca %MixedB
20         %ArrayA  = alloca %MixedA, uint 4
21         %ArrayB  = alloca %MixedB, uint 3
22
23         %I1 = getelementptr %MixedA* %ScalarA, long 0, uint 0   
24         store float 0x3FF6A09020000000, float *%I1
25         %I2 = getelementptr %MixedB* %ScalarB, long 0, uint 1, uint 0 
26         store float 0x4005BF1420000000, float *%I2
27         
28         %fptrA = getelementptr %MixedA* %ArrayA, long 1, uint 0 
29         %fptrB = getelementptr %MixedB* %ArrayB, long 2, uint 1, uint 0 
30         
31         store float 0x400921CAC0000000, float* %fptrA
32         store float 5.0,    float* %fptrB
33         
34         ;; Test that a sequence of GEPs with constant indices are folded right
35         %fptrA1 = getelementptr %MixedA* %ArrayA, long 3          ; &ArrayA[3]
36         %fptrA2 = getelementptr %MixedA* %fptrA1, long 0, uint 1 ; &(*fptrA1).1
37         %fptrA3 = getelementptr [15 x int]* %fptrA2, long 0, long 8 ; &(*fptrA2)[8]
38         store int 5, int* %fptrA3       ; ArrayA[3].1[8] = 5
39
40         %sqrtTwo = load float *%I1
41         %exp     = load float *%I2
42         %I3 = getelementptr %MixedA* %ArrayA, long 1, uint 0 
43         %pi      = load float* %I3
44         %I4 = getelementptr %MixedB* %ArrayB, long 2, uint 1, uint 0  
45         %five    = load float* %I4
46                  
47         %dsqrtTwo = cast float %sqrtTwo to double
48         %dexp     = cast float %exp to double
49         %dpi      = cast float %pi to double
50         %dfive    = cast float %five to double
51                   
52         %castFmt = getelementptr [44 x sbyte]* %fmtArg, long 0, long 0
53         call int (sbyte*, ...)* %printf(sbyte* %castFmt, double %dsqrtTwo, double %dexp, double %dpi, double %dfive)
54         
55         ret int 0
56 end