Sink dag combine's post index load / store code that swap base ptr and index into...
[oota-llvm.git] / test / CodeGen / Generic / 2007-11-21-UndeadIllegalNode.ll
1 ; RUN: llc < %s -o -
2
3         %struct.RETURN = type { i32, i32 }
4         %struct.ada__finalization__controlled = type { %struct.system__finalization_root__root_controlled }
5         %struct.ada__streams__root_stream_type = type { %struct.ada__tags__dispatch_table* }
6         %struct.ada__strings__unbounded__string_access = type { i8*, %struct.RETURN* }
7         %struct.ada__strings__unbounded__unbounded_string = type { %struct.ada__finalization__controlled, %struct.ada__strings__unbounded__string_access, i32 }
8         %struct.ada__tags__dispatch_table = type { [1 x i32] }
9         %struct.exception = type { i8, i8, i32, i8*, i8*, i32, i8* }
10         %struct.system__finalization_root__root_controlled = type { %struct.ada__streams__root_stream_type, %struct.system__finalization_root__root_controlled*, %struct.system__finalization_root__root_controlled* }
11         %struct.system__standard_library__exception_data = type { i8, i8, i32, i32, %struct.system__standard_library__exception_data*, i32, void ()* }
12 @C.495.7639 = internal constant %struct.RETURN { i32 1, i32 16 }                ; <%struct.RETURN*> [#uses=1]
13 @ada__strings__index_error = external global %struct.exception          ; <%struct.exception*> [#uses=1]
14 @.str5 = internal constant [16 x i8] c"a-strunb.adb:690"                ; <[16 x i8]*> [#uses=1]
15
16 declare void @llvm.memcpy.i32(i8*, i8*, i32, i32)
17
18 declare void @ada__strings__unbounded__realloc_for_chunk(%struct.ada__strings__unbounded__unbounded_string*, i32)
19
20 declare void @__gnat_raise_exception(%struct.system__standard_library__exception_data*, i64)
21
22 define void @ada__strings__unbounded__insert__2(%struct.ada__strings__unbounded__unbounded_string* %source, i32 %before, i64 %new_item.0.0) {
23 entry:
24         %tmp24636 = lshr i64 %new_item.0.0, 32          ; <i64> [#uses=1]
25         %tmp24637 = trunc i64 %tmp24636 to i32          ; <i32> [#uses=1]
26         %tmp24638 = inttoptr i32 %tmp24637 to %struct.RETURN*           ; <%struct.RETURN*> [#uses=2]
27         %tmp25 = getelementptr %struct.RETURN* %tmp24638, i32 0, i32 0          ; <i32*> [#uses=1]
28         %tmp26 = load i32* %tmp25, align 4              ; <i32> [#uses=1]
29         %tmp29 = getelementptr %struct.RETURN* %tmp24638, i32 0, i32 1          ; <i32*> [#uses=1]
30         %tmp30 = load i32* %tmp29, align 4              ; <i32> [#uses=1]
31         %tmp63 = getelementptr %struct.ada__strings__unbounded__unbounded_string* %source, i32 0, i32 1, i32 1          ; <%struct.RETURN**> [#uses=5]
32         %tmp64 = load %struct.RETURN** %tmp63, align 4          ; <%struct.RETURN*> [#uses=1]
33         %tmp65 = getelementptr %struct.RETURN* %tmp64, i32 0, i32 0             ; <i32*> [#uses=1]
34         %tmp66 = load i32* %tmp65, align 4              ; <i32> [#uses=1]
35         %tmp67 = icmp sgt i32 %tmp66, %before           ; <i1> [#uses=1]
36         br i1 %tmp67, label %bb77, label %bb
37
38 bb:             ; preds = %entry
39         %tmp71 = getelementptr %struct.ada__strings__unbounded__unbounded_string* %source, i32 0, i32 2         ; <i32*> [#uses=4]
40         %tmp72 = load i32* %tmp71, align 4              ; <i32> [#uses=1]
41         %tmp73 = add i32 %tmp72, 1              ; <i32> [#uses=1]
42         %tmp74 = icmp slt i32 %tmp73, %before           ; <i1> [#uses=1]
43         br i1 %tmp74, label %bb77, label %bb84
44
45 bb77:           ; preds = %bb, %entry
46         tail call void @__gnat_raise_exception( %struct.system__standard_library__exception_data* bitcast (%struct.exception* @ada__strings__index_error to %struct.system__standard_library__exception_data*), i64 or (i64 zext (i32 ptrtoint ([16 x i8]* @.str5 to i32) to i64), i64 shl (i64 zext (i32 ptrtoint (%struct.RETURN* @C.495.7639 to i32) to i64), i64 32)) )
47         unreachable
48
49 bb84:           ; preds = %bb
50         %tmp93 = sub i32 %tmp30, %tmp26         ; <i32> [#uses=2]
51         %tmp9394 = sext i32 %tmp93 to i36               ; <i36> [#uses=1]
52         %tmp95 = shl i36 %tmp9394, 3            ; <i36> [#uses=1]
53         %tmp96 = add i36 %tmp95, 8              ; <i36> [#uses=2]
54         %tmp97 = icmp sgt i36 %tmp96, -1                ; <i1> [#uses=1]
55         %tmp100 = select i1 %tmp97, i36 %tmp96, i36 0           ; <i36> [#uses=2]
56         %tmp101 = icmp slt i36 %tmp100, 17179869177             ; <i1> [#uses=1]
57         %tmp100.cast = trunc i36 %tmp100 to i32         ; <i32> [#uses=1]
58         %min102 = select i1 %tmp101, i32 %tmp100.cast, i32 -8           ; <i32> [#uses=1]
59         tail call void @ada__strings__unbounded__realloc_for_chunk( %struct.ada__strings__unbounded__unbounded_string* %source, i32 %min102 )
60         %tmp148 = load i32* %tmp71, align 4             ; <i32> [#uses=4]
61         %tmp152 = add i32 %tmp93, 1             ; <i32> [#uses=2]
62         %tmp153 = icmp sgt i32 %tmp152, -1              ; <i1> [#uses=1]
63         %max154 = select i1 %tmp153, i32 %tmp152, i32 0         ; <i32> [#uses=5]
64         %tmp155 = add i32 %tmp148, %max154              ; <i32> [#uses=5]
65         %tmp315 = getelementptr %struct.ada__strings__unbounded__unbounded_string* %source, i32 0, i32 1, i32 0         ; <i8**> [#uses=4]
66         %tmp328 = load %struct.RETURN** %tmp63, align 4         ; <%struct.RETURN*> [#uses=1]
67         %tmp329 = getelementptr %struct.RETURN* %tmp328, i32 0, i32 0           ; <i32*> [#uses=1]
68         %tmp330 = load i32* %tmp329, align 4            ; <i32> [#uses=4]
69         %tmp324 = add i32 %max154, %before              ; <i32> [#uses=3]
70         %tmp331 = sub i32 %tmp324, %tmp330              ; <i32> [#uses=1]
71         %tmp349 = sub i32 %before, %tmp330              ; <i32> [#uses=1]
72         %tmp356 = icmp sgt i32 %tmp331, %tmp349         ; <i1> [#uses=1]
73         %tmp431 = icmp sgt i32 %tmp324, %tmp155         ; <i1> [#uses=2]
74         br i1 %tmp356, label %bb420, label %bb359
75
76 bb359:          ; preds = %bb84
77         br i1 %tmp431, label %bb481, label %bb382
78
79 bb382:          ; preds = %bb382, %bb359
80         %indvar = phi i32 [ 0, %bb359 ], [ %indvar.next, %bb382 ]               ; <i32> [#uses=2]
81         %max379.pn = phi i32 [ %max154, %bb359 ], [ %L492b.0, %bb382 ]          ; <i32> [#uses=1]
82         %before.pn = phi i32 [ %before, %bb359 ], [ 1, %bb382 ]         ; <i32> [#uses=1]
83         %L492b.0 = add i32 %before.pn, %max379.pn               ; <i32> [#uses=3]
84         %tmp386 = load %struct.RETURN** %tmp63, align 4         ; <%struct.RETURN*> [#uses=1]
85         %tmp387 = getelementptr %struct.RETURN* %tmp386, i32 0, i32 0           ; <i32*> [#uses=1]
86         %tmp388 = load i32* %tmp387, align 4            ; <i32> [#uses=2]
87         %tmp392 = load i8** %tmp315, align 4            ; <i8*> [#uses=2]
88         %R493b.0 = add i32 %indvar, %before             ; <i32> [#uses=1]
89         %tmp405 = sub i32 %R493b.0, %tmp388             ; <i32> [#uses=1]
90         %tmp406 = getelementptr i8* %tmp392, i32 %tmp405                ; <i8*> [#uses=1]
91         %tmp407 = load i8* %tmp406, align 1             ; <i8> [#uses=1]
92         %tmp408 = sub i32 %L492b.0, %tmp388             ; <i32> [#uses=1]
93         %tmp409 = getelementptr i8* %tmp392, i32 %tmp408                ; <i8*> [#uses=1]
94         store i8 %tmp407, i8* %tmp409, align 1
95         %tmp414 = icmp eq i32 %L492b.0, %tmp155         ; <i1> [#uses=1]
96         %indvar.next = add i32 %indvar, 1               ; <i32> [#uses=1]
97         br i1 %tmp414, label %bb481, label %bb382
98
99 bb420:          ; preds = %bb84
100         br i1 %tmp431, label %bb481, label %bb436.preheader
101
102 bb436.preheader:                ; preds = %bb420
103         %tmp4468 = load i8** %tmp315, align 4           ; <i8*> [#uses=2]
104         %tmp4599 = sub i32 %tmp148, %tmp330             ; <i32> [#uses=1]
105         %tmp46010 = getelementptr i8* %tmp4468, i32 %tmp4599            ; <i8*> [#uses=1]
106         %tmp46111 = load i8* %tmp46010, align 1         ; <i8> [#uses=1]
107         %tmp46212 = sub i32 %tmp155, %tmp330            ; <i32> [#uses=1]
108         %tmp46313 = getelementptr i8* %tmp4468, i32 %tmp46212           ; <i8*> [#uses=1]
109         store i8 %tmp46111, i8* %tmp46313, align 1
110         %exitcond14 = icmp eq i32 %tmp155, %tmp324              ; <i1> [#uses=1]
111         br i1 %exitcond14, label %bb481, label %bb.nph
112
113 bb.nph:         ; preds = %bb436.preheader
114         %tmp5 = sub i32 %tmp148, %before                ; <i32> [#uses=1]
115         br label %bb478
116
117 bb478:          ; preds = %bb478, %bb.nph
118         %indvar6422 = phi i32 [ 0, %bb.nph ], [ %indvar.next643, %bb478 ]               ; <i32> [#uses=1]
119         %indvar.next643 = add i32 %indvar6422, 1                ; <i32> [#uses=4]
120         %L490b.0 = sub i32 %tmp155, %indvar.next643             ; <i32> [#uses=1]
121         %R491b.0 = sub i32 %tmp148, %indvar.next643             ; <i32> [#uses=1]
122         %tmp440 = load %struct.RETURN** %tmp63, align 4         ; <%struct.RETURN*> [#uses=1]
123         %tmp441 = getelementptr %struct.RETURN* %tmp440, i32 0, i32 0           ; <i32*> [#uses=1]
124         %tmp442 = load i32* %tmp441, align 4            ; <i32> [#uses=2]
125         %tmp446 = load i8** %tmp315, align 4            ; <i8*> [#uses=2]
126         %tmp459 = sub i32 %R491b.0, %tmp442             ; <i32> [#uses=1]
127         %tmp460 = getelementptr i8* %tmp446, i32 %tmp459                ; <i8*> [#uses=1]
128         %tmp461 = load i8* %tmp460, align 1             ; <i8> [#uses=1]
129         %tmp462 = sub i32 %L490b.0, %tmp442             ; <i32> [#uses=1]
130         %tmp463 = getelementptr i8* %tmp446, i32 %tmp462                ; <i8*> [#uses=1]
131         store i8 %tmp461, i8* %tmp463, align 1
132         %exitcond = icmp eq i32 %indvar.next643, %tmp5          ; <i1> [#uses=1]
133         br i1 %exitcond, label %bb481, label %bb478
134
135 bb481:          ; preds = %bb478, %bb436.preheader, %bb420, %bb382, %bb359
136         %tmp577 = add i32 %before, -1           ; <i32> [#uses=3]
137         %tmp578 = add i32 %max154, %tmp577              ; <i32> [#uses=2]
138         %tmp581 = icmp sge i32 %tmp578, %tmp577         ; <i1> [#uses=1]
139         %max582 = select i1 %tmp581, i32 %tmp578, i32 %tmp577           ; <i32> [#uses=1]
140         %tmp584 = sub i32 %max582, %before              ; <i32> [#uses=1]
141         %tmp585 = add i32 %tmp584, 1            ; <i32> [#uses=2]
142         %tmp586 = icmp sgt i32 %tmp585, -1              ; <i1> [#uses=1]
143         %max587 = select i1 %tmp586, i32 %tmp585, i32 0         ; <i32> [#uses=1]
144         %tmp591 = load %struct.RETURN** %tmp63, align 4         ; <%struct.RETURN*> [#uses=1]
145         %tmp592 = getelementptr %struct.RETURN* %tmp591, i32 0, i32 0           ; <i32*> [#uses=1]
146         %tmp593 = load i32* %tmp592, align 4            ; <i32> [#uses=1]
147         %tmp597 = load i8** %tmp315, align 4            ; <i8*> [#uses=1]
148         %tmp600621 = trunc i64 %new_item.0.0 to i32             ; <i32> [#uses=1]
149         %tmp600622 = inttoptr i32 %tmp600621 to i8*             ; <i8*> [#uses=1]
150         %tmp601 = sub i32 %before, %tmp593              ; <i32> [#uses=1]
151         %tmp602 = getelementptr i8* %tmp597, i32 %tmp601                ; <i8*> [#uses=1]
152         tail call void @llvm.memcpy.i32( i8* %tmp602, i8* %tmp600622, i32 %max587, i32 1 )
153         %tmp606 = load i32* %tmp71, align 4             ; <i32> [#uses=1]
154         %tmp613 = add i32 %tmp606, %max154              ; <i32> [#uses=1]
155         store i32 %tmp613, i32* %tmp71, align 4
156         ret void
157 }