tut-simplify-cfg2-dead-block-order.ll
1.96 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
; 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 @remove_dead_blocks() {
; CHECK-LABEL: @remove_dead_blocks(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i32 1
; CHECK-NEXT: }
;
entry:
ret i32 1
bb.1:
ret i32 2
bb.2:
ret i32 3
}
define i32 @simp1() {
; CHECK-LABEL: @simp1(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i32 1
; CHECK: bb.1:
; CHECK-NEXT: ret i32 2
; CHECK-NEXT: }
;
entry:
ret i32 1
bb.1:
ret i32 2
bb.2:
br i1 undef, label %bb.1, label %bb.3
bb.3:
ret i32 3
}
define i32 @remove_dead_block_with_phi() {
; CHECK-LABEL: @remove_dead_block_with_phi(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[BB_2:%.*]]
; CHECK: bb.2:
; CHECK-NEXT: ret i32 1
; CHECK-NEXT: }
;
entry:
br label %bb.2
bb.1:
br label %bb.2
bb.2:
%rv = phi i32 [ 1, %entry ], [ 2, %bb.1 ]
ret i32 %rv
}
define i32 @remove_dead_blocks_remaining_uses(i32 %a) {
; CHECK-LABEL: @remove_dead_blocks_remaining_uses(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i32 1
; CHECK-NEXT: }
;
entry:
ret i32 1
bb.2:
ret i32 %res
bb.1:
%res = add i32 %a, 10
br label %bb.2
}
define i32 @remove_dead_blocks_remaining_uses2(i32 %a, i1 %cond) {
; CHECK-LABEL: @remove_dead_blocks_remaining_uses2(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i32 1
; CHECK: bb.2:
; CHECK-NEXT: [[RES2:%.*]] = add i32 undef, 10
; CHECK-NEXT: [[RES3:%.*]] = mul i32 [[RES2]], undef
; CHECK-NEXT: ret i32 [[RES3]]
; CHECK: bb.3:
; CHECK-NEXT: ret i32 undef
; CHECK-NEXT: }
;
entry:
ret i32 1
bb.2:
%res2 = add i32 %res, 10
%res3 = mul i32 %res2, %res
ret i32 %res3
bb.3:
br label %bb.4
bb.4:
ret i32 %res
bb.1:
%res = add i32 %a, 10
br i1 %cond, label %bb.2, label %bb.3
br label %bb.2
}