1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=instcombine -S < %s | FileCheck %s
3 target triple = "x86_64-pc-windows-msvc"
5 define i1 @test1(ptr %p) personality ptr @__CxxFrameHandler3 {
8 ; CHECK-NEXT: [[A:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 1
9 ; CHECK-NEXT: invoke void @may_throw()
10 ; CHECK-NEXT: to label [[INVOKE_CONT:%.*]] unwind label [[CATCH_DISPATCH:%.*]]
12 ; CHECK-NEXT: [[B:%.*]] = getelementptr i8, ptr [[P]], i64 2
13 ; CHECK-NEXT: invoke void @may_throw()
14 ; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[CATCH_DISPATCH]]
15 ; CHECK: catch.dispatch:
16 ; CHECK-NEXT: [[C:%.*]] = phi ptr [ [[B]], [[INVOKE_CONT]] ], [ [[A]], [[ENTRY:%.*]] ]
17 ; CHECK-NEXT: [[TMP1:%.*]] = catchswitch within none [label %catch] unwind to caller
19 ; CHECK-NEXT: [[TMP2:%.*]] = catchpad within [[TMP1]] [ptr null, i32 64, ptr null]
20 ; CHECK-NEXT: catchret from [[TMP2]] to label [[EXIT]]
22 ; CHECK-NEXT: [[D:%.*]] = phi ptr [ [[A]], [[INVOKE_CONT]] ], [ [[C]], [[CATCH:%.*]] ]
23 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[D]], [[A]]
24 ; CHECK-NEXT: ret i1 [[CMP]]
27 %a = getelementptr i8, ptr %p, i64 1
28 invoke void @may_throw()
29 to label %invoke.cont unwind label %catch.dispatch
32 %b = getelementptr inbounds i8, ptr %a, i64 1
33 invoke void @may_throw()
34 to label %exit unwind label %catch.dispatch
37 %c = phi ptr [ %b, %invoke.cont ], [ %a, %entry ]
38 %tmp1 = catchswitch within none [label %catch] unwind to caller
41 %tmp2 = catchpad within %tmp1 [ptr null, i32 64, ptr null]
42 catchret from %tmp2 to label %exit
45 %d = phi ptr [ %a, %invoke.cont ], [ %c, %catch ]
46 %cmp = icmp eq ptr %d, %a
50 declare void @may_throw()
52 declare i32 @__CxxFrameHandler3(...)