tut-simplify-cfg3-phis.ll
1.34 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -tut-simplifycfg -tut-simplifycfg-version=v1 -S < %s | FileCheck %s
; RUN: opt -tut-simplifycfg -tut-simplifycfg-version=v2 -S < %s | FileCheck %s
; RUN: opt -tut-simplifycfg -tut-simplifycfg-version=v3 -S < %s | FileCheck %s
define i32 @phi_cond_branch_eliminated() {
; CHECK-LABEL: @phi_cond_branch_eliminated(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i32 20
;
entry:
br i1 true, label %bb.2, label %bb.3
bb.2:
br label %bb.3
bb.3:
%ret = phi i32 [ 10, %entry ], [ 20, %bb.2 ]
ret i32 %ret
}
define i32 @phi_removed() {
; CHECK-LABEL: @phi_removed(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[BB_3:%.*]]
; CHECK: bb.3:
; CHECK-NEXT: ret i32 0
;
entry:
br i1 false, label %bb.2, label %bb.3
bb.2:
%pv = phi i32 [ 10, %entry ]
br label %bb.3
bb.3:
ret i32 0
}
define i32 @phi_in_dead_region() {
; CHECK-LABEL: @phi_in_dead_region(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i32 1
;
entry:
ret i32 1
bb.1:
br i1 true, label %bb.2, label %bb.3
bb.2:
br label %bb.3
bb.3:
%ret = phi i32 [ 10, %bb.1 ], [ 20, %bb.2 ]
ret i32 %ret
}
define i32 @phi_in_mergable_blocks() {
; CHECK-LABEL: @phi_in_mergable_blocks(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i32 10
;
entry:
br label %bb.1
bb.1:
%pv = phi i32 [ 10, %entry ]
ret i32 %pv
}