Use the llvm-upgrade program to upgrade llvm assembly.
[oota-llvm.git] / test / Transforms / InstCombine / load.ll
1 ; This test makes sure that these instructions are properly eliminated.
2 ;
3
4 ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | not grep load
5
6 %X = constant int 42
7 %X2 = constant int 47
8 %Y = constant [2 x { int, float }] [ { int, float } { int 12, float 1.0 }, 
9                                      { int, float } { int 37, float 1.2312 } ]
10 %Z = constant [2 x { int, float }] zeroinitializer
11
12 int %test1() {
13         %B = load int* %X
14         ret int %B
15 }
16
17 float %test2() {
18         %A = getelementptr [2 x { int, float}]* %Y, long 0, long 1, uint 1
19         %B = load float* %A
20         ret float %B
21 }
22
23
24 int %test3() {
25         %A = getelementptr [2 x { int, float}]* %Y, long 0, long 0, uint 0
26         %B = load int* %A
27         ret int %B
28 }
29
30 int %test4() {
31         %A = getelementptr [2 x { int, float}]* %Z, long 0, long 1, uint 0
32         %B = load int* %A
33         ret int %B
34 }
35
36 ; load (select (Cond, &V1, &V2))  --> select(Cond, load &V1, load &V2)
37 int %test5(bool %C) {
38         %Y = select bool %C, int* %X, int* %X2
39         %Z = load int* %Y
40         ret int %Z
41 }
42
43 int %test7(int %X) {
44         %V = getelementptr int* null, int %X
45         %R = load int* %V
46         ret int %R
47 }
48
49 int %test8(int* %P) {
50         store int 1, int* %P
51         %X = load int* %P        ;; Trivial store->load forwarding
52         ret int %X
53 }
54
55 int %test9(int* %P) {
56         %X = load int* %P        ;; Trivial load cse
57         %Y = load int* %P
58         %Z = sub int %X, %Y
59         ret int %Z
60 }
61
62 int %test10(bool %C, int* %P, int* %Q) {
63         br bool %C, label %T, label %F
64 T:
65         store int 1, int* %Q
66         store int 0, int* %P
67         br label %C
68 F:
69         store int 0, int* %P
70         br label %C
71 C:
72         %V = load int* %P   ;; always 0
73         ret int %V
74 }