Skip to content

Commit 08b2332

Browse files
danpoemartin
authored and
martin
committed
disable two-way propagation for now
1 parent 76abe8a commit 08b2332

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/analyses/constant_propagator.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ void constant_propagator_domaint::transform(
6161
dynamic_cast<constant_propagator_ait *>(&ai);
6262
bool have_dirty=(cp!=nullptr);
6363

64-
if(values.is_bottom)
65-
return;
64+
assert(!values.is_bottom);
6665

6766
if(from->is_decl())
6867
{
@@ -95,6 +94,12 @@ void constant_propagator_domaint::transform(
9594
else
9695
{
9796
two_way_propagate_rec(g, ns);
97+
// If two way propagate is enabled then it may be possible to detect
98+
// that the branch condition is infeasible and thus the domain should
99+
// be set to bottom. Without it the domain will only be set to bottom
100+
// if the guard expression is trivially (i.e. without context) false.
101+
INVARIANT(!values.is_bottom,
102+
"Without two-way propagation this should be impossible.");
98103
}
99104
}
100105
else if(from->is_dead())
@@ -192,6 +197,9 @@ void constant_propagator_domaint::transform(
192197
}
193198
}
194199

200+
INVARIANT(from->is_goto() || !values.is_bottom,
201+
"Transform only sets bottom by using branch conditions");
202+
195203
#ifdef DEBUG
196204
std::cout << "After:\n";
197205
output(std::cout, ai, ns);
@@ -210,6 +218,7 @@ bool constant_propagator_domaint::two_way_propagate_rec(
210218

211219
bool change=false;
212220

221+
#if 0
213222
if(expr.id()==ID_and)
214223
{
215224
// need a fixed point here to get the most out of it
@@ -219,7 +228,7 @@ bool constant_propagator_domaint::two_way_propagate_rec(
219228

220229
forall_operands(it, expr)
221230
if(two_way_propagate_rec(*it, ns))
222-
change = true;
231+
change=true;
223232
}
224233
while(change);
225234
}
@@ -229,12 +238,13 @@ bool constant_propagator_domaint::two_way_propagate_rec(
229238
const exprt &rhs=expr.op1();
230239

231240
// two-way propagation
232-
valuest copy_values = values;
241+
valuest copy_values=values;
233242
assign_rec(copy_values, lhs, rhs, ns);
234243
if(!values.is_constant(rhs) || values.is_constant(lhs))
235244
assign_rec(values, rhs, lhs, ns);
236-
change = values.meet(copy_values);
245+
change=values.meet(copy_values);
237246
}
247+
#endif
238248

239249
#ifdef DEBUG
240250
std::cout << "two_way_propagate_rec: " << change << '\n';

0 commit comments

Comments
 (0)