1 ; RUN: opt < %s -loop-reduce -S | FileCheck %s
3 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
4 target triple = "i686-pc-windows-msvc"
6 declare i32 @_except_handler3(...)
7 declare i32 @__CxxFrameHandler3(...)
9 declare void @external(i32*)
10 declare void @reserve()
12 define void @f() personality i32 (...)* @_except_handler3 {
16 throw: ; preds = %throw, %entry
17 %tmp96 = getelementptr inbounds i8, i8* undef, i32 1
18 invoke void @reserve()
19 to label %throw unwind label %pad
22 %phi2 = phi i8* [ %tmp96, %throw ]
23 terminatepad [] unwind label %blah
26 catchpad [] to label %unreachable unwind label %blah3
32 catchendpad unwind label %blah2
35 %cleanuppadi4.i.i.i = cleanuppad []
38 loop_body: ; preds = %iter, %pad
39 %tmp99 = phi i8* [ %tmp101, %iter ], [ %phi2, %blah2 ]
40 %tmp100 = icmp eq i8* %tmp99, undef
41 br i1 %tmp100, label %unwind_out, label %iter
43 iter: ; preds = %loop_body
44 %tmp101 = getelementptr inbounds i8, i8* %tmp99, i32 1
45 br i1 undef, label %unwind_out, label %loop_body
47 unwind_out: ; preds = %iter, %loop_body
48 cleanupret %cleanuppadi4.i.i.i unwind to caller
51 ; CHECK-LABEL: define void @f(
52 ; CHECK: cleanuppad []
53 ; CHECK-NEXT: ptrtoint i8* %phi2 to i32
55 define void @g() personality i32 (...)* @_except_handler3 {
59 throw: ; preds = %throw, %entry
60 %tmp96 = getelementptr inbounds i8, i8* undef, i32 1
61 invoke void @reserve()
62 to label %throw unwind label %pad
65 %phi2 = phi i8* [ %tmp96, %throw ]
66 catchpad [] to label %unreachable unwind label %blah
72 %catchpad = catchpad [] to label %loop_body unwind label %blah3
76 catchendpad unwind to caller ;label %blah2
79 catchret %catchpad to label %leave
84 loop_body: ; preds = %iter, %pad
85 %tmp99 = phi i8* [ %tmp101, %iter ], [ %phi2, %blah ]
86 %tmp100 = icmp eq i8* %tmp99, undef
87 br i1 %tmp100, label %unwind_out, label %iter
89 iter: ; preds = %loop_body
90 %tmp101 = getelementptr inbounds i8, i8* %tmp99, i32 1
91 br i1 undef, label %unwind_out, label %loop_body
94 ; CHECK-LABEL: define void @g(
96 ; CHECK-NEXT: catchpad []
97 ; CHECK-NEXT: to label %loop_body.preheader
99 ; CHECK: loop_body.preheader:
100 ; CHECK-NEXT: ptrtoint i8* %phi2 to i32
103 define void @h() personality i32 (...)* @_except_handler3 {
107 throw: ; preds = %throw, %entry
108 %tmp96 = getelementptr inbounds i8, i8* undef, i32 1
109 invoke void @reserve()
110 to label %throw unwind label %pad
113 catchpad [] to label %unreachable unwind label %blug
119 %phi2 = phi i8* [ %tmp96, %pad ]
120 %catchpad = catchpad [] to label %blah2 unwind label %blah3
126 catchendpad unwind to caller ;label %blah2
129 catchret %catchpad to label %leave
134 loop_body: ; preds = %iter, %pad
135 %tmp99 = phi i8* [ %tmp101, %iter ], [ %phi2, %blah2 ]
136 %tmp100 = icmp eq i8* %tmp99, undef
137 br i1 %tmp100, label %unwind_out, label %iter
139 iter: ; preds = %loop_body
140 %tmp101 = getelementptr inbounds i8, i8* %tmp99, i32 1
141 br i1 undef, label %unwind_out, label %loop_body
144 ; CHECK-LABEL: define void @h(
147 ; CHECK-NEXT: to label %blah2
150 ; CHECK-NEXT: ptrtoint i8* %phi2 to i32
152 define void @i() personality i32 (...)* @_except_handler3 {
156 throw: ; preds = %throw, %entry
157 %tmp96 = getelementptr inbounds i8, i8* undef, i32 1
158 invoke void @reserve()
159 to label %throw unwind label %catchpad
161 catchpad: ; preds = %throw
162 %phi2 = phi i8* [ %tmp96, %throw ]
163 catchpad [] to label %cp_body unwind label %catchendpad
169 catchendpad unwind label %cleanuppad
178 loop_body: ; preds = %iter, %catchpad
179 %tmp99 = phi i8* [ %tmp101, %iter ], [ %phi2, %loop_head ]
180 %tmp100 = icmp eq i8* %tmp99, undef
181 br i1 %tmp100, label %unwind_out, label %iter
183 iter: ; preds = %loop_body
184 %tmp101 = getelementptr inbounds i8, i8* %tmp99, i32 1
185 br i1 undef, label %unwind_out, label %loop_body
187 unwind_out: ; preds = %iter, %loop_body
191 ; CHECK-LABEL: define void @i(
192 ; CHECK: ptrtoint i8* %phi2 to i32
194 define void @test1(i32* %b, i32* %c) personality i32 (...)* @__CxxFrameHandler3 {
198 for.cond: ; preds = %for.inc, %entry
199 %d.0 = phi i32* [ %b, %entry ], [ %incdec.ptr, %for.inc ]
200 invoke void @external(i32* %d.0)
201 to label %for.inc unwind label %catch.dispatch
203 for.inc: ; preds = %for.cond
204 %incdec.ptr = getelementptr inbounds i32, i32* %d.0, i32 1
207 catch.dispatch: ; preds = %for.cond
208 %0 = catchpad [i8* null, i32 64, i8* null]
209 to label %catch unwind label %catchendblock
211 catchendblock: ; preds = %catch.dispatch
212 catchendpad unwind label %catch.dispatch.2
214 catch: ; preds = %catch.dispatch
215 catchret %0 to label %try.cont
217 try.cont: ; preds = %catch
218 invoke void @external(i32* %c)
219 to label %try.cont.7 unwind label %catch.dispatch.2
221 catch.dispatch.2: ; preds = %try.cont, %catchendblock
222 %e.0 = phi i32* [ %c, %try.cont ], [ %b, %catchendblock ]
223 %1 = catchpad [i8* null, i32 64, i8* null]
224 to label %catch.4 unwind label %catchendblock.3
226 catch.4: ; preds = %catch.dispatch.2
229 try.cont.7: ; preds = %try.cont
232 catchendblock.3: ; preds = %catch.dispatch.2
233 catchendpad unwind to caller
236 ; CHECK-LABEL: define void @test1(
238 ; CHECK: %d.0 = phi i32* [ %b, %entry ], [ %incdec.ptr, %for.inc ]
240 ; CHECK: catchendpad unwind label %catch.dispatch.2
242 ; CHECK: catch.dispatch.2:
243 ; CHECK: %e.0 = phi i32* [ %c, %try.cont ], [ %b, %catchendblock ]