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(...)
8 declare void @reserve()
10 define void @f() personality i32 (...)* @_except_handler3 {
14 throw: ; preds = %throw, %entry
15 %tmp96 = getelementptr inbounds i8, i8* undef, i32 1
16 invoke void @reserve()
17 to label %throw unwind label %pad
20 %phi2 = phi i8* [ %tmp96, %throw ]
21 terminatepad [] unwind label %blah
24 catchpad [] to label %unreachable unwind label %blah3
30 catchendpad unwind label %blah2
33 %cleanuppadi4.i.i.i = cleanuppad []
36 loop_body: ; preds = %iter, %pad
37 %tmp99 = phi i8* [ %tmp101, %iter ], [ %phi2, %blah2 ]
38 %tmp100 = icmp eq i8* %tmp99, undef
39 br i1 %tmp100, label %unwind_out, label %iter
41 iter: ; preds = %loop_body
42 %tmp101 = getelementptr inbounds i8, i8* %tmp99, i32 1
43 br i1 undef, label %unwind_out, label %loop_body
45 unwind_out: ; preds = %iter, %loop_body
46 cleanupret %cleanuppadi4.i.i.i unwind to caller
49 ; CHECK-LABEL: define void @f(
50 ; CHECK: cleanuppad []
51 ; CHECK-NEXT: ptrtoint i8* %phi2 to i32
53 define void @g() personality i32 (...)* @_except_handler3 {
57 throw: ; preds = %throw, %entry
58 %tmp96 = getelementptr inbounds i8, i8* undef, i32 1
59 invoke void @reserve()
60 to label %throw unwind label %pad
63 %phi2 = phi i8* [ %tmp96, %throw ]
64 catchpad [] to label %unreachable unwind label %blah
70 %catchpad = catchpad [] to label %loop_body unwind label %blah3
74 catchendpad unwind to caller ;label %blah2
77 catchret %catchpad to label %leave
82 loop_body: ; preds = %iter, %pad
83 %tmp99 = phi i8* [ %tmp101, %iter ], [ %phi2, %blah ]
84 %tmp100 = icmp eq i8* %tmp99, undef
85 br i1 %tmp100, label %unwind_out, label %iter
87 iter: ; preds = %loop_body
88 %tmp101 = getelementptr inbounds i8, i8* %tmp99, i32 1
89 br i1 undef, label %unwind_out, label %loop_body
92 ; CHECK-LABEL: define void @g(
94 ; CHECK-NEXT: catchpad []
95 ; CHECK-NEXT: to label %loop_body.preheader
97 ; CHECK: loop_body.preheader:
98 ; CHECK-NEXT: ptrtoint i8* %phi2 to i32
101 define void @h() personality i32 (...)* @_except_handler3 {
105 throw: ; preds = %throw, %entry
106 %tmp96 = getelementptr inbounds i8, i8* undef, i32 1
107 invoke void @reserve()
108 to label %throw unwind label %pad
111 catchpad [] to label %unreachable unwind label %blug
117 %phi2 = phi i8* [ %tmp96, %pad ]
118 %catchpad = catchpad [] to label %blah2 unwind label %blah3
124 catchendpad unwind to caller ;label %blah2
127 catchret %catchpad to label %leave
132 loop_body: ; preds = %iter, %pad
133 %tmp99 = phi i8* [ %tmp101, %iter ], [ %phi2, %blah2 ]
134 %tmp100 = icmp eq i8* %tmp99, undef
135 br i1 %tmp100, label %unwind_out, label %iter
137 iter: ; preds = %loop_body
138 %tmp101 = getelementptr inbounds i8, i8* %tmp99, i32 1
139 br i1 undef, label %unwind_out, label %loop_body
142 ; CHECK-LABEL: define void @h(
145 ; CHECK-NEXT: to label %blah2
148 ; CHECK-NEXT: ptrtoint i8* %phi2 to i32