Regression test for the Instruction Combining optimizization.
[oota-llvm.git] / test / Transforms / InstCombine / 2003-07-21-ExternalConstant.ll
1 ;
2 ; Test: ExternalConstant
3 ;
4 ; Description:
5 ;       This regression test helps check whether the instruction combining
6 ;       optimization pass correctly handles global variables which are marked
7 ;       as external and constant.
8 ;
9 ;       If a problem occurs, we should die on an assert().  Otherwise, we
10 ;       should pass through the optimizer without failure.
11 ;
12 ; Extra code:
13 ; RUN: as < %s | opt -instcombine
14 ;
15
16 target endian = little
17 target pointersize = 32
18 %silly = external constant int          ; <int*> [#uses=1]
19
20 implementation   ; Functions:
21
22 declare void %bzero(sbyte*, uint)
23
24 declare void %bcopy(sbyte*, sbyte*, uint)
25
26 declare int %bcmp(sbyte*, sbyte*, uint)
27
28 declare int %fputs(sbyte*, sbyte*)
29
30 declare int %fputs_unlocked(sbyte*, sbyte*)
31
32 int %function(int %a.1) {
33 entry:          ; No predecessors!
34         %a.0 = alloca int               ; <int*> [#uses=2]
35         %result = alloca int            ; <int*> [#uses=2]
36         store int %a.1, int* %a.0
37         %tmp.0 = load int* %a.0         ; <int> [#uses=1]
38         %tmp.1 = load int* %silly               ; <int> [#uses=1]
39         %tmp.2 = add int %tmp.0, %tmp.1         ; <int> [#uses=1]
40         store int %tmp.2, int* %result
41         br label %return
42
43 return:         ; preds = %entry
44         %tmp.3 = load int* %result              ; <int> [#uses=1]
45         ret int %tmp.3
46 }