Skip to content

Commit 2171833

Browse files
Petr BauchThomas Kiley
authored andcommitted
Assume relation between two symbols
1 parent b27b828 commit 2171833

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

src/analyses/interval_domain.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,10 @@ void interval_domaint::assume_rec(
329329
{
330330
integer_intervalt &lhs_i=int_map[lhs_identifier];
331331
integer_intervalt &rhs_i=int_map[rhs_identifier];
332-
lhs_i.meet(rhs_i);
333-
rhs_i=lhs_i;
334-
if(rhs_i.is_bottom())
335-
make_bottom();
332+
if(id == ID_lt && !lhs_i.is_less_than(rhs_i))
333+
lhs_i.make_less_than(rhs_i);
334+
if(id == ID_le && !lhs_i.is_less_than_eq(rhs_i))
335+
lhs_i.make_less_than_eq(rhs_i);
336336
}
337337
else if(is_float(lhs.type()) && is_float(rhs.type()))
338338
{

src/util/interval_template.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,47 @@ template<class T> class interval_templatet
143143
}
144144
}
145145

146+
void make_bottom()
147+
{
148+
lower_set = upper_set = true;
149+
upper = T();
150+
lower = upper + 1;
151+
}
152+
153+
void make_less_than_eq(interval_templatet &i)
154+
{
155+
if(upper_set && i.upper_set)
156+
upper = std::min(upper, i.upper);
157+
if(lower_set && i.lower_set)
158+
i.lower = std::max(lower, i.lower);
159+
}
160+
161+
void make_less_than(interval_templatet &i)
162+
{
163+
make_less_than_eq(i);
164+
if(singleton() && i.singleton() && lower == i.lower)
165+
{
166+
make_bottom();
167+
i.make_bottom();
168+
}
169+
}
170+
171+
bool is_less_than_eq(const interval_templatet &i)
172+
{
173+
if(i.lower_set && upper_set && upper <= i.lower)
174+
return true;
175+
else
176+
return false;
177+
}
178+
179+
bool is_less_than(const interval_templatet &i)
180+
{
181+
if(i.lower_set && upper_set && upper < i.lower)
182+
return true;
183+
else
184+
return false;
185+
}
186+
146187
void approx_union_with(const interval_templatet &i)
147188
{
148189
if(i.lower_set && lower_set)

0 commit comments

Comments
 (0)