1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -loop-reduce -S | FileCheck %s
3 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-pc-windows-msvc18.0.0"
6 %struct.L = type { i8, ptr }
8 declare i32 @__CxxFrameHandler3(...)
10 @GV1 = external global ptr
11 @GV2 = external global %struct.L
13 define void @b_copy_ctor() personality ptr @__CxxFrameHandler3 {
14 ; CHECK-LABEL: @b_copy_ctor(
16 ; CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr @GV1, align 8
17 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
19 ; CHECK-NEXT: [[LSR_IV:%.*]] = phi i64 [ [[LSR_IV_NEXT:%.*]], [[CALL_I_NOEXC:%.*]] ], [ 0, [[ENTRY:%.*]] ]
20 ; CHECK-NEXT: [[LSR_IV2:%.*]] = inttoptr i64 [[LSR_IV]] to ptr
21 ; CHECK-NEXT: invoke void @a_copy_ctor()
22 ; CHECK-NEXT: to label [[CALL_I_NOEXC]] unwind label [[CATCH_DISPATCH:%.*]]
23 ; CHECK: call.i.noexc:
24 ; CHECK-NEXT: [[LSR_IV_NEXT]] = add i64 [[LSR_IV]], -16
25 ; CHECK-NEXT: br label [[FOR_COND]]
26 ; CHECK: catch.dispatch:
27 ; CHECK-NEXT: [[TMP2:%.*]] = catchswitch within none [label %catch] unwind to caller
29 ; CHECK-NEXT: [[TMP3:%.*]] = catchpad within [[TMP2]] [ptr null, i32 64, ptr null]
30 ; CHECK-NEXT: [[CMP16:%.*]] = icmp eq ptr [[LSR_IV2]], null
31 ; CHECK-NEXT: [[TMP4:%.*]] = mul i64 [[LSR_IV]], -1
32 ; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[TMP0]], i64 [[TMP4]]
33 ; CHECK-NEXT: br i1 [[CMP16]], label [[FOR_END:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
34 ; CHECK: for.body.preheader:
35 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
37 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[UGLYGEP]], @GV2
38 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_END_LOOPEXIT:%.*]], label [[FOR_BODY]]
39 ; CHECK: for.end.loopexit:
40 ; CHECK-NEXT: br label [[FOR_END]]
42 ; CHECK-NEXT: catchret from [[TMP3]] to label [[TRY_CONT:%.*]]
44 ; CHECK-NEXT: ret void
47 %0 = load ptr, ptr @GV1, align 8
50 for.cond: ; preds = %call.i.noexc, %entry
51 %d.0 = phi ptr [ %0, %entry ], [ %incdec.ptr, %call.i.noexc ]
52 invoke void @a_copy_ctor()
53 to label %call.i.noexc unwind label %catch.dispatch
55 call.i.noexc: ; preds = %for.cond
56 %incdec.ptr = getelementptr inbounds %struct.L, ptr %d.0, i64 1
59 catch.dispatch: ; preds = %for.cond
60 %1 = catchswitch within none [label %catch] unwind to caller
62 catch: ; preds = %catch.dispatch
63 %2 = catchpad within %1 [ptr null, i32 64, ptr null]
64 %cmp16 = icmp eq ptr %0, %d.0
65 br i1 %cmp16, label %for.end, label %for.body
67 for.body: ; preds = %for.body, %catch
68 %cmp = icmp eq ptr @GV2, %d.0
69 br i1 %cmp, label %for.end, label %for.body
71 for.end: ; preds = %for.body, %catch
72 catchret from %2 to label %try.cont
74 try.cont: ; preds = %for.end
78 declare void @a_copy_ctor()