Adding RUN lines.
[oota-llvm.git] / test / CodeGen / Generic / 2003-05-30-BadFoldGEP.ll
1 ; RUN: llvm-as -f %s -o - | llc
2
3 ;; Date:     May 28, 2003.
4 ;; From:     test/Programs/External/SPEC/CINT2000/254.gap.llvm.bc
5 ;; Function: int %OpenOutput(sbyte* %filename.1)
6 ;;
7 ;; Error:    A sequence of GEPs is folded incorrectly by llc during selection
8 ;;           causing an assertion about a dynamic casting error.
9 ;;           This code sequence was produced (correctly) by preselection
10 ;;           from a nested pair of ConstantExpr getelementptrs.
11 ;;           The code below is the output of preselection.
12 ;;           The original ConstantExprs are included in a comment.
13 ;;
14 ;; Cause:    FoldGetElemChain() was inserting an extra leading 0 even though
15 ;;           the first instruction in the sequence contributes no indices.
16 ;;           The next instruction contributes a leading non-zero so another
17 ;;           zero should not be added before it!
18 ;;
19
20
21 %FileType = type { int, [256 x sbyte], int, int, int, int }
22 %OutputFiles = uninitialized global [16 x %FileType]
23 %Output = internal global %FileType* null
24
25
26 implementation; Functions:
27
28 internal int %OpenOutput(sbyte* %filename.1) {
29 entry:
30         %tmp.0 = load %FileType** %Output      
31         %tmp.4 = getelementptr %FileType* %tmp.0, long 1
32
33         ;;------ Original instruction in 254.gap.llvm.bc:
34         ;; %tmp.10 = seteq { int, [256 x sbyte], int, int, int, int }* %tmp.4, getelementptr ([16 x { int, [256 x sbyte], int, int, int, int }]* getelementptr ([16 x { int, [256 x sbyte], int, int, int, int }]* %OutputFiles, long 1), long 0, long 0)
35
36         ;;------ Code sequence produced by preselection phase for above instr:
37         ;; This code sequence is folded incorrectly by llc during selection
38         ;; causing an assertion about a dynamic casting error.
39         %addrOfGlobal = getelementptr [16 x %FileType]* %OutputFiles, long 0
40         %constantGEP = getelementptr [16 x %FileType]* %addrOfGlobal, long 1
41         %constantGEP = getelementptr [16 x %FileType]* %constantGEP, long 0, long 0
42         %tmp.10 = seteq %FileType* %tmp.4, %constantGEP
43         br bool %tmp.10, label %return, label %endif.0
44
45 endif.0:
46         ret int 0
47
48 return:
49         ret int 1
50 }