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, i8* }
8 declare i32 @__CxxFrameHandler3(...)
10 @GV1 = external global %struct.L*
11 @GV2 = external global %struct.L
13 define void @b_copy_ctor() personality i32 (...)* @__CxxFrameHandler3 {
14 ; CHECK-LABEL: @b_copy_ctor(
16 ; CHECK-NEXT: [[TMP0:%.*]] = load %struct.L*, %struct.L** @GV1, align 8
17 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast %struct.L* [[TMP0]] to i8*
18 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
20 ; CHECK-NEXT: [[LSR_IV:%.*]] = phi i64 [ [[LSR_IV_NEXT:%.*]], [[CALL_I_NOEXC:%.*]] ], [ 0, [[ENTRY:%.*]] ]
21 ; CHECK-NEXT: [[LSR_IV2:%.*]] = inttoptr i64 [[LSR_IV]] to %struct.L*
22 ; CHECK-NEXT: invoke void @a_copy_ctor()
23 ; CHECK-NEXT: to label [[CALL_I_NOEXC]] unwind label [[CATCH_DISPATCH:%.*]]
24 ; CHECK: call.i.noexc:
25 ; CHECK-NEXT: [[LSR_IV_NEXT]] = add i64 [[LSR_IV]], -16
26 ; CHECK-NEXT: br label [[FOR_COND]]
27 ; CHECK: catch.dispatch:
28 ; CHECK-NEXT: [[TMP2:%.*]] = catchswitch within none [label %catch] unwind to caller
30 ; CHECK-NEXT: [[TMP3:%.*]] = catchpad within [[TMP2]] [i8* null, i32 64, i8* null]
31 ; CHECK-NEXT: [[CMP16:%.*]] = icmp eq %struct.L* [[LSR_IV2]], null
32 ; CHECK-NEXT: [[TMP4:%.*]] = mul i64 [[LSR_IV]], -1
33 ; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, i8* [[TMP1]], i64 [[TMP4]]
34 ; CHECK-NEXT: [[UGLYGEP1:%.*]] = bitcast i8* [[UGLYGEP]] to %struct.L*
35 ; CHECK-NEXT: br i1 [[CMP16]], label [[FOR_END:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
36 ; CHECK: for.body.preheader:
37 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
39 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq %struct.L* [[UGLYGEP1]], @GV2
40 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_END_LOOPEXIT:%.*]], label [[FOR_BODY]]
41 ; CHECK: for.end.loopexit:
42 ; CHECK-NEXT: br label [[FOR_END]]
44 ; CHECK-NEXT: catchret from [[TMP3]] to label [[TRY_CONT:%.*]]
46 ; CHECK-NEXT: ret void
49 %0 = load %struct.L*, %struct.L** @GV1, align 8
52 for.cond: ; preds = %call.i.noexc, %entry
53 %d.0 = phi %struct.L* [ %0, %entry ], [ %incdec.ptr, %call.i.noexc ]
54 invoke void @a_copy_ctor()
55 to label %call.i.noexc unwind label %catch.dispatch
57 call.i.noexc: ; preds = %for.cond
58 %incdec.ptr = getelementptr inbounds %struct.L, %struct.L* %d.0, i64 1
61 catch.dispatch: ; preds = %for.cond
62 %1 = catchswitch within none [label %catch] unwind to caller
64 catch: ; preds = %catch.dispatch
65 %2 = catchpad within %1 [i8* null, i32 64, i8* null]
66 %cmp16 = icmp eq %struct.L* %0, %d.0
67 br i1 %cmp16, label %for.end, label %for.body
69 for.body: ; preds = %for.body, %catch
70 %cmp = icmp eq %struct.L* @GV2, %d.0
71 br i1 %cmp, label %for.end, label %for.body
73 for.end: ; preds = %for.body, %catch
74 catchret from %2 to label %try.cont
76 try.cont: ; preds = %for.end
80 declare void @a_copy_ctor()