1; RUN: opt < %s -loop-reduce -S | FileCheck %s
2target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
3target triple = "x86_64-pc-windows-msvc18.0.0"
4
5%struct.L = type { i8, i8* }
6
7declare i32 @__CxxFrameHandler3(...)
8
9@GV1 = external global %struct.L*
10@GV2 = external global %struct.L
11
12define void @b_copy_ctor() personality i32 (...)* @__CxxFrameHandler3 {
13entry:
14  %0 = load %struct.L*, %struct.L** @GV1, align 8
15  br label %for.cond
16
17for.cond:                                         ; preds = %call.i.noexc, %entry
18  %d.0 = phi %struct.L* [ %0, %entry ], [ %incdec.ptr, %call.i.noexc ]
19  invoke void @a_copy_ctor()
20          to label %call.i.noexc unwind label %catch.dispatch
21
22call.i.noexc:                                     ; preds = %for.cond
23  %incdec.ptr = getelementptr inbounds %struct.L, %struct.L* %d.0, i64 1
24  br label %for.cond
25
26catch.dispatch:                                   ; preds = %for.cond
27  %1 = catchswitch within none [label %catch] unwind to caller
28
29catch:                                            ; preds = %catch.dispatch
30  %2 = catchpad within %1 [i8* null, i32 64, i8* null]
31  %cmp16 = icmp eq %struct.L* %0, %d.0
32  br i1 %cmp16, label %for.end, label %for.body
33
34for.body:                                         ; preds = %for.body, %catch
35  %cmp = icmp eq %struct.L* @GV2, %d.0
36  br i1 %cmp, label %for.end, label %for.body
37
38for.end:                                          ; preds = %for.body, %catch
39  catchret from %2 to label %try.cont
40
41try.cont:                                         ; preds = %for.end
42  ret void
43}
44
45; CHECK-LABEL: define void @b_copy_ctor(
46; CHECK:       catchpad
47; CHECK-NEXT:  icmp eq %struct.L
48; CHECK-NEXT:  getelementptr {{.*}} i64 sub (i64 0, i64 ptrtoint (%struct.L* @GV2 to i64))
49
50declare void @a_copy_ctor()
51