trivial-checks.ll
5.68 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -indvars -S < %s | FileCheck %s
; RUN: opt -passes=indvars -S < %s | FileCheck %s
; FIXME: In all cases, x is from [0; 1000) and we cannot prove that x + 1 > x.
define void @test_sgt(i32 %x) {
; CHECK-LABEL: @test_sgt(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[PRECONDITION:%.*]] = icmp ult i32 [[X:%.*]], 1000
; CHECK-NEXT: br i1 [[PRECONDITION]], label [[LOOP_PREHEADER:%.*]], label [[EXIT:%.*]]
; CHECK: loop.preheader:
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: loop:
; CHECK-NEXT: [[IV:%.*]] = phi i32 [ [[IV_NEXT:%.*]], [[GUARDED:%.*]] ], [ [[X]], [[LOOP_PREHEADER]] ]
; CHECK-NEXT: [[TMP:%.*]] = add i32 [[IV]], 1
; CHECK-NEXT: [[GUARD:%.*]] = icmp sgt i32 [[TMP]], [[IV]]
; CHECK-NEXT: br i1 [[GUARD]], label [[GUARDED]], label [[FAIL:%.*]]
; CHECK: guarded:
; CHECK-NEXT: [[IV_NEXT]] = add i32 [[IV]], -1
; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[IV]], 0
; CHECK-NEXT: br i1 [[COND]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]]
; CHECK: exit.loopexit:
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: ret void
; CHECK: fail:
; CHECK-NEXT: unreachable
;
entry:
%precondition = icmp ult i32 %x, 1000
br i1 %precondition, label %loop, label %exit
loop:
%iv = phi i32 [%x, %entry], [%iv.next, %guarded]
%tmp = add i32 %iv, 1
%guard = icmp sgt i32 %tmp, %iv
br i1 %guard, label %guarded, label %fail
guarded:
%iv.next = add i32 %iv, -1
%cond = icmp eq i32 %iv, 0
br i1 %cond, label %loop, label %exit
exit:
ret void
fail:
unreachable
}
define void @test_sge(i32 %x) {
; CHECK-LABEL: @test_sge(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[PRECONDITION:%.*]] = icmp ult i32 [[X:%.*]], 1000
; CHECK-NEXT: br i1 [[PRECONDITION]], label [[LOOP_PREHEADER:%.*]], label [[EXIT:%.*]]
; CHECK: loop.preheader:
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: loop:
; CHECK-NEXT: [[IV:%.*]] = phi i32 [ [[IV_NEXT:%.*]], [[GUARDED:%.*]] ], [ [[X]], [[LOOP_PREHEADER]] ]
; CHECK-NEXT: [[TMP:%.*]] = add i32 [[IV]], 1
; CHECK-NEXT: [[GUARD:%.*]] = icmp sge i32 [[TMP]], [[IV]]
; CHECK-NEXT: br i1 [[GUARD]], label [[GUARDED]], label [[FAIL:%.*]]
; CHECK: guarded:
; CHECK-NEXT: [[IV_NEXT]] = add i32 [[IV]], -1
; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[IV]], 0
; CHECK-NEXT: br i1 [[COND]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]]
; CHECK: exit.loopexit:
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: ret void
; CHECK: fail:
; CHECK-NEXT: unreachable
;
entry:
%precondition = icmp ult i32 %x, 1000
br i1 %precondition, label %loop, label %exit
loop:
%iv = phi i32 [%x, %entry], [%iv.next, %guarded]
%tmp = add i32 %iv, 1
%guard = icmp sge i32 %tmp, %iv
br i1 %guard, label %guarded, label %fail
guarded:
%iv.next = add i32 %iv, -1
%cond = icmp eq i32 %iv, 0
br i1 %cond, label %loop, label %exit
exit:
ret void
fail:
unreachable
}
define void @test_ugt(i32 %x) {
; CHECK-LABEL: @test_ugt(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[PRECONDITION:%.*]] = icmp ult i32 [[X:%.*]], 1000
; CHECK-NEXT: br i1 [[PRECONDITION]], label [[LOOP_PREHEADER:%.*]], label [[EXIT:%.*]]
; CHECK: loop.preheader:
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: loop:
; CHECK-NEXT: [[IV:%.*]] = phi i32 [ [[IV_NEXT:%.*]], [[GUARDED:%.*]] ], [ [[X]], [[LOOP_PREHEADER]] ]
; CHECK-NEXT: [[TMP:%.*]] = add i32 [[IV]], 1
; CHECK-NEXT: [[GUARD:%.*]] = icmp ugt i32 [[TMP]], [[IV]]
; CHECK-NEXT: br i1 [[GUARD]], label [[GUARDED]], label [[FAIL:%.*]]
; CHECK: guarded:
; CHECK-NEXT: [[IV_NEXT]] = add i32 [[IV]], -1
; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[IV]], 0
; CHECK-NEXT: br i1 [[COND]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]]
; CHECK: exit.loopexit:
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: ret void
; CHECK: fail:
; CHECK-NEXT: unreachable
;
entry:
%precondition = icmp ult i32 %x, 1000
br i1 %precondition, label %loop, label %exit
loop:
%iv = phi i32 [%x, %entry], [%iv.next, %guarded]
%tmp = add i32 %iv, 1
%guard = icmp ugt i32 %tmp, %iv
br i1 %guard, label %guarded, label %fail
guarded:
%iv.next = add i32 %iv, -1
%cond = icmp eq i32 %iv, 0
br i1 %cond, label %loop, label %exit
exit:
ret void
fail:
unreachable
}
define void @test_uge(i32 %x) {
; CHECK-LABEL: @test_uge(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[PRECONDITION:%.*]] = icmp ult i32 [[X:%.*]], 1000
; CHECK-NEXT: br i1 [[PRECONDITION]], label [[LOOP_PREHEADER:%.*]], label [[EXIT:%.*]]
; CHECK: loop.preheader:
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: loop:
; CHECK-NEXT: [[IV:%.*]] = phi i32 [ [[IV_NEXT:%.*]], [[GUARDED:%.*]] ], [ [[X]], [[LOOP_PREHEADER]] ]
; CHECK-NEXT: [[TMP:%.*]] = add i32 [[IV]], 1
; CHECK-NEXT: [[GUARD:%.*]] = icmp uge i32 [[TMP]], [[IV]]
; CHECK-NEXT: br i1 [[GUARD]], label [[GUARDED]], label [[FAIL:%.*]]
; CHECK: guarded:
; CHECK-NEXT: [[IV_NEXT]] = add i32 [[IV]], -1
; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[IV]], 0
; CHECK-NEXT: br i1 [[COND]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]]
; CHECK: exit.loopexit:
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: ret void
; CHECK: fail:
; CHECK-NEXT: unreachable
;
entry:
%precondition = icmp ult i32 %x, 1000
br i1 %precondition, label %loop, label %exit
loop:
%iv = phi i32 [%x, %entry], [%iv.next, %guarded]
%tmp = add i32 %iv, 1
%guard = icmp uge i32 %tmp, %iv
br i1 %guard, label %guarded, label %fail
guarded:
%iv.next = add i32 %iv, -1
%cond = icmp eq i32 %iv, 0
br i1 %cond, label %loop, label %exit
exit:
ret void
fail:
unreachable
}