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