Skip to content

Commit 02a6288

Browse files
committed
Avoid use of sort_and_join in guard operations
1 parent 0696c4e commit 02a6288

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

src/goto-symex/goto_symex_state.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ class goto_symex_statet
193193
value_sett value_set;
194194
guardt guard;
195195
symex_targett::sourcet source;
196+
guardt guard_before_branch;
196197
propagationt propagation;
197198
unsigned atomic_section_id;
198199

src/goto-symex/symex_goto.cpp

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ void goto_symext::symex_goto(statet &state)
175175
state.rename(guard_expr, ns);
176176
}
177177

178+
new_state.guard_before_branch=state.guard;
178179
if(forward)
179180
{
180181
new_state.guard.add(guard_expr);
@@ -280,10 +281,38 @@ void goto_symext::phi_function(
280281

281282
if(!variables.empty())
282283
{
283-
diff_guard=goto_state.guard;
284+
guardt tmp_guard(goto_state.guard);
285+
guardt tmp_guard2(goto_state.guard);
284286

285287
// this gets the diff between the guards
286-
diff_guard-=dest_state.guard;
288+
// tmp_guard-=dest_state.guard;
289+
if(!goto_state.guard_before_branch.is_constant())
290+
{
291+
assert(tmp_guard2.id()==ID_and);
292+
293+
if(goto_state.guard_before_branch.id()==ID_and)
294+
{
295+
assert(tmp_guard2.operands().size()>
296+
goto_state.guard_before_branch.operands().size());
297+
for(const auto & op : goto_state.guard_before_branch.operands())
298+
{
299+
// assert(tmp_guard2.operands().front()==op);
300+
(void)op;
301+
tmp_guard2.operands().erase(tmp_guard2.operands().begin());
302+
}
303+
}
304+
else
305+
{
306+
assert(tmp_guard2.operands().front()==
307+
goto_state.guard_before_branch);
308+
tmp_guard2.operands().erase(tmp_guard2.operands().begin());
309+
}
310+
311+
if(tmp_guard2.operands().size()==1)
312+
tmp_guard2=tmp_guard2.op0();
313+
}
314+
// assert(tmp_guard==tmp_guard2);
315+
diff_guard=tmp_guard2;
287316
}
288317

289318
for(std::unordered_set<ssa_exprt, irep_hash>::const_iterator

src/util/guard.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,22 @@ guardt& guardt::logical_or(const guardt &g2, const namespacet &ns)
132132
if(g2.is_false() || g1.is_true()) return g1;
133133
if(g1.is_false() || g2.is_true()) { g1=g2; return g1; }
134134

135+
{
136+
exprt tmp(g2);
137+
tmp.make_not();
138+
139+
if(tmp==g1)
140+
g1.make_true();
141+
else
142+
g1=or_exprt(g1, g2);
143+
144+
bdd_exprt t(ns);
145+
t.from_expr(g1);
146+
g1=t.as_expr();
147+
148+
return g1;
149+
}
150+
135151
if(g1.id()!=ID_and || g2.id()!=ID_and)
136152
{
137153
exprt tmp(g2);

0 commit comments

Comments
 (0)