1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
| ; RUN: opt < %s -simplifycfg -sink-common-insts -S | FileCheck %s
; RUN: opt < %s -passes='simplify-cfg<sink-common-insts>' -S | FileCheck %s
define i1 @test1(i1 zeroext %flag, i8* %y) #0 {
entry:
br i1 %flag, label %if.then, label %if.else
if.then:
%r = call i1 @llvm.type.test(i8* %y, metadata !0)
br label %if.end
if.else:
%s = call i1 @llvm.type.test(i8* %y, metadata !1)
br label %if.end
if.end:
%t = phi i1 [ %s, %if.else ], [ %r, %if.then ]
ret i1 %t
}
!0 = !{i32 0, !"typeid1"}
!1 = !{i32 4, !"typeid1"}
declare i1 @llvm.type.test(i8* %ptr, metadata %bitset) nounwind readnone
; CHECK-LABEL: test1
; CHECK: @llvm.type.test
; CHECK: @llvm.type.test
; CHECK: ret i1
define i1 @test2(i1 zeroext %flag, i8* %y, i8* %z) #0 {
entry:
br i1 %flag, label %if.then, label %if.else
if.then:
%r = call i1 @llvm.type.test(i8* %y, metadata !0)
br label %if.end
if.else:
%s = call i1 @llvm.type.test(i8* %z, metadata !0)
br label %if.end
if.end:
%t = phi i1 [ %s, %if.else ], [ %r, %if.then ]
ret i1 %t
}
; CHECK-LABEL: test2
; CHECK: %[[S:[a-z0-9.]+]] = select i1 %flag, i8* %y, i8* %z
; CHECK: %[[R:[a-z0-9.]+]] = call i1 @llvm.type.test(i8* %[[S]], metadata !0)
; CHECK: ret i1 %[[R]]
|