implied-cond-matching-imm.ll
2.11 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
; RUN: opt %s -S -simplifycfg | FileCheck %s
; cmp1 implies cmp2 is false
; CHECK-LABEL: @test1
; CHECK-NOT: call void @is(i1 true)
; CHECK: call void @is(i1 false)
define void @test1(i32 %a) {
%cmp1 = icmp eq i32 %a, 0
br i1 %cmp1, label %taken, label %untaken
taken:
%cmp2 = icmp eq i32 %a, 1
br i1 %cmp2, label %istrue, label %isfalse
istrue:
call void @is(i1 true)
ret void
isfalse:
call void @is(i1 false)
ret void
untaken:
ret void
}
; cmp1 implies cmp2 is false
; CHECK-LABEL: @test2
; CHECK-NOT: call void @is(i1 true)
; CHECK: call void @is(i1 false)
define void @test2(i32 %a) {
%cmp1 = icmp ugt i32 %a, 5
br i1 %cmp1, label %untaken, label %taken
taken:
%cmp2 = icmp ugt i32 %a, 6
br i1 %cmp2, label %istrue, label %isfalse
istrue:
call void @is(i1 true)
ret void
isfalse:
call void @is(i1 false)
ret void
untaken:
ret void
}
; cmp1 implies cmp2 is false
; CHECK-LABEL: @test3
; CHECK-NOT: call void @is(i1 true)
; CHECK: call void @is(i1 false)
define void @test3(i32 %a) {
%cmp1 = icmp ugt i32 %a, 1
br i1 %cmp1, label %taken, label %untaken
taken:
%cmp2 = icmp eq i32 %a, 0
br i1 %cmp2, label %istrue, label %isfalse
istrue:
call void @is(i1 true)
ret void
isfalse:
call void @is(i1 false)
ret void
untaken:
ret void
}
; cmp1 implies cmp2 is true
; CHECK-LABEL: @test4
; CHECK: call void @is(i1 true)
; CHECK-NOT: call void @is(i1 false)
define void @test4(i32 %a) {
%cmp1 = icmp sgt i32 %a, 1
br i1 %cmp1, label %taken, label %untaken
taken:
%cmp2 = icmp ugt i32 %a, 0
br i1 %cmp2, label %istrue, label %isfalse
istrue:
call void @is(i1 true)
ret void
isfalse:
call void @is(i1 false)
ret void
untaken:
ret void
}
; cmp1 implies cmp2 is true
; CHECK-LABEL: @test5
; CHECK: call void @is(i1 true)
; CHECK-NOT: call void @is(i1 false)
define void @test5(i32 %a) {
%cmp1 = icmp sgt i32 %a, 5
br i1 %cmp1, label %taken, label %untaken
taken:
%cmp2 = icmp sgt i32 %a, -1
br i1 %cmp2, label %istrue, label %isfalse
istrue:
call void @is(i1 true)
ret void
isfalse:
call void @is(i1 false)
ret void
untaken:
ret void
}
declare void @is(i1)