1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -sink-common-insts -S | FileCheck %s
3 ; RUN: opt < %s -passes='simplifycfg<sink-common-insts>' -S | FileCheck %s
5 define i1 @test1(i1 zeroext %flag, ptr %y) #0 {
8 ; CHECK-NEXT: [[S:%.*]] = call i1 @llvm.type.test(ptr [[Y:%.*]], metadata [[META0:![0-9]+]])
9 ; CHECK-NEXT: [[R:%.*]] = call i1 @llvm.type.test(ptr [[Y]], metadata [[META1:![0-9]+]])
10 ; CHECK-NEXT: [[T:%.*]] = select i1 [[FLAG:%.*]], i1 [[R]], i1 [[S]]
11 ; CHECK-NEXT: ret i1 [[T]]
14 br i1 %flag, label %if.then, label %if.else
17 %r = call i1 @llvm.type.test(ptr %y, metadata !0)
21 %s = call i1 @llvm.type.test(ptr %y, metadata !1)
25 %t = phi i1 [ %s, %if.else ], [ %r, %if.then ]
29 !0 = !{i32 0, !"typeid1"}
30 !1 = !{i32 4, !"typeid1"}
32 declare i1 @llvm.type.test(ptr %ptr, metadata %bitset) nounwind readnone
34 define i1 @test2(i1 zeroext %flag, ptr %y, ptr %z) #0 {
35 ; CHECK-LABEL: @test2(
37 ; CHECK-NEXT: [[Y_Z:%.*]] = select i1 [[FLAG:%.*]], ptr [[Y:%.*]], ptr [[Z:%.*]]
38 ; CHECK-NEXT: [[S:%.*]] = call i1 @llvm.type.test(ptr [[Y_Z]], metadata [[META1]])
39 ; CHECK-NEXT: ret i1 [[S]]
42 br i1 %flag, label %if.then, label %if.else
45 %r = call i1 @llvm.type.test(ptr %y, metadata !0)
49 %s = call i1 @llvm.type.test(ptr %z, metadata !0)
53 %t = phi i1 [ %s, %if.else ], [ %r, %if.then ]