freeze-lvi-edgevaluelocal.ll
2.04 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
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -jump-threading -S < %s | FileCheck %s
declare void @f()
declare void @f2()
declare void @f3()
; br on cond.fr should be removed & ENTRY -> A -> B should be threaded
define i32 @simple(i1 %cond) {
; CHECK-LABEL: @simple(
; CHECK-NEXT: ENTRY:
; CHECK-NEXT: br i1 [[COND:%.*]], label [[B:%.*]], label [[EXIT:%.*]]
; CHECK: B:
; CHECK-NEXT: call void @f()
; CHECK-NEXT: ret i32 1
; CHECK: EXIT:
; CHECK-NEXT: ret i32 0
;
ENTRY:
%cond.fr = freeze i1 %cond
br i1 %cond, label %A, label %EXIT
A:
br i1 %cond.fr, label %B, label %EXIT
B:
call void @f()
ret i32 1
EXIT:
ret i32 0
}
define void @switch(i32 %cond) {
; CHECK-LABEL: @switch(
; CHECK-NEXT: ENTRY:
; CHECK-NEXT: [[COND_FR:%.*]] = freeze i32 [[COND:%.*]]
; CHECK-NEXT: switch i32 [[COND]], label [[DEFAULT:%.*]] [
; CHECK-NEXT: i32 0, label [[A_TAKEN:%.*]]
; CHECK-NEXT: i32 1, label [[B_TAKEN:%.*]]
; CHECK-NEXT: ]
; CHECK: DEFAULT:
; CHECK-NEXT: switch i32 [[COND_FR]], label [[PRESERVED1:%.*]] [
; CHECK-NEXT: i32 0, label [[PRESERVED2:%.*]]
; CHECK-NEXT: ]
; CHECK: PRESERVED1:
; CHECK-NEXT: call void @f()
; CHECK-NEXT: ret void
; CHECK: PRESERVED2:
; CHECK-NEXT: call void @f2()
; CHECK-NEXT: ret void
; CHECK: A_TAKEN:
; CHECK-NEXT: call void @f()
; CHECK-NEXT: ret void
; CHECK: B_TAKEN:
; CHECK-NEXT: call void @f()
; CHECK-NEXT: ret void
;
ENTRY:
%cond.fr = freeze i32 %cond
switch i32 %cond, label %DEFAULT [
i32 0, label %A
i32 1, label %B
]
DEFAULT:
switch i32 %cond.fr, label %PRESERVED1 [
i32 0, label %PRESERVED2
]
PRESERVED1:
call void @f()
ret void
PRESERVED2:
call void @f2()
ret void
A:
switch i32 %cond.fr, label %A_NOTTAKEN [
i32 0, label %A_TAKEN
]
A_TAKEN:
call void @f()
ret void
A_NOTTAKEN:
call void @f2()
ret void
B:
switch i32 %cond.fr, label %B_TAKEN [
i32 0, label %B_NOTTAKEN
]
B_TAKEN:
call void @f()
ret void
B_NOTTAKEN:
call void @f2()
ret void
}