1 ; RUN: llvm-as -f %s -o - | llc
4 ;; From: test/Programs/External/SPEC/CINT2000/254.gap.llvm.bc
5 ;; Function: int %OpenOutput(sbyte* %filename.1)
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.
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!
21 %FileType = type { int, [256 x sbyte], int, int, int, int }
22 %OutputFiles = uninitialized global [16 x %FileType]
23 %Output = internal global %FileType* null
26 implementation; Functions:
28 internal int %OpenOutput(sbyte* %filename.1) {
30 %tmp.0 = load %FileType** %Output
31 %tmp.4 = getelementptr %FileType* %tmp.0, long 1
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)
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