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