[RS4GC] Use "deopt" operand bundles
[oota-llvm.git] / test / Transforms / RewriteStatepointsForGC / deopt-bundles / codegen-cond.ll
1 ; RUN: opt -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -S < %s | FileCheck %s
2
3 ; A null test of a single value
4
5 define i1 @test(i8 addrspace(1)* %p, i1 %rare) gc "statepoint-example" {
6 ; CHECK-LABEL: @test
7 entry:
8   %cond = icmp eq i8 addrspace(1)* %p, null
9   br i1 %rare, label %safepoint, label %continue, !prof !0
10
11 safepoint:                                        ; preds = %entry
12   call void @safepoint() [ "deopt"() ]
13   br label %continue
14
15 continue:                                         ; preds = %safepoint, %entry
16 ; CHECK-LABEL: continue:
17 ; CHECK: phi
18 ; CHECK-DAG: [ %p.relocated, %safepoint ]
19 ; CHECK-DAG: [ %p, %entry ]
20 ; CHECK: %cond = icmp
21 ; CHECK: br i1 %cond
22 ; Comparing two pointers
23   br i1 %cond, label %taken, label %untaken
24
25 taken:                                            ; preds = %continue
26   ret i1 true
27
28 untaken:                                          ; preds = %continue
29   ret i1 false
30 }
31
32 define i1 @test2(i8 addrspace(1)* %p, i8 addrspace(1)* %q, i1 %rare) gc "statepoint-example" {
33 ; CHECK-LABEL: @test2
34 entry:
35   %cond = icmp eq i8 addrspace(1)* %p, %q
36   br i1 %rare, label %safepoint, label %continue, !prof !0
37
38 safepoint:                                        ; preds = %entry
39   call void @safepoint() [ "deopt"() ]
40   br label %continue
41
42 continue:                                         ; preds = %safepoint, %entry
43 ; CHECK-LABEL: continue:
44 ; CHECK: phi
45 ; CHECK-DAG: [ %q.relocated, %safepoint ]
46 ; CHECK-DAG: [ %q, %entry ]
47 ; CHECK: phi
48 ; CHECK-DAG: [ %p.relocated, %safepoint ]
49 ; CHECK-DAG: [ %p, %entry ]
50 ; CHECK: %cond = icmp
51 ; CHECK: br i1 %cond
52 ; Sanity check that nothing bad happens if already last instruction
53 ; before terminator
54   br i1 %cond, label %taken, label %untaken
55
56 taken:                                            ; preds = %continue
57   ret i1 true
58
59 untaken:                                          ; preds = %continue
60   ret i1 false
61 }
62
63 define i1 @test3(i8 addrspace(1)* %p, i8 addrspace(1)* %q, i1 %rare) gc "statepoint-example" {
64 ; CHECK-LABEL: @test3
65 ; CHECK: gc.statepoint
66 ; CHECK: %cond = icmp
67 ; CHECK: br i1 %cond
68 entry:
69   call void @safepoint() [ "deopt"() ]
70   %cond = icmp eq i8 addrspace(1)* %p, %q
71   br i1 %cond, label %taken, label %untaken
72
73 taken:                                            ; preds = %entry
74   ret i1 true
75
76 untaken:                                          ; preds = %entry
77   ret i1 false
78 }
79
80 declare void @safepoint()
81 !0 = !{!"branch_weights", i32 1, i32 10000}