Skip to content

Commit bf08eee

Browse files
author
Daniel Kroening
authored
Merge pull request #375 from tautschnig/trivial-loops
Turn "label: goto label;" or "while(cond);" into assume
2 parents 95284f5 + e672e0d commit bf08eee

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/goto-symex/symex_goto.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,27 @@ void goto_symext::symex_goto(statet &state)
6969

7070
if(!forward) // backwards?
7171
{
72+
// is it label: goto label; or while(cond); - popular in SV-COMP
73+
if(goto_target==state.source.pc ||
74+
(instruction.incoming_edges.size()==1 &&
75+
*instruction.incoming_edges.begin()==goto_target))
76+
{
77+
// generate assume(false) or a suitable negation if this
78+
// instruction is a conditional goto
79+
exprt negated_cond;
80+
81+
if(new_guard.is_true())
82+
negated_cond=false_exprt();
83+
else
84+
negated_cond=not_exprt(new_guard);
85+
86+
symex_assume(state, negated_cond);
87+
88+
// next instruction
89+
state.source.pc++;
90+
return;
91+
}
92+
7293
unsigned &unwind=
7394
frame.loop_iterations[goto_programt::loop_id(state.source.pc)].count;
7495
unwind++;

0 commit comments

Comments
 (0)