Skip to content

Commit 87794c5

Browse files
committed
Re-enable two-way constant propagation
It has only been disabled on suspicion of being at fault for bugs, but these are quite possibly due to other bugs (cf. soundness fixes later in this series).
1 parent fe8d1db commit 87794c5

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <assert.h>
2+
3+
int main()
4+
{
5+
int x;
6+
if(x == 0)
7+
{
8+
assert(!x);
9+
}
10+
return 0;
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--constants --verify
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^\[main.assertion.1\] line 8 assertion !x: SUCCESS$
7+
--
8+
^warning: ignoring

src/analyses/constant_propagator.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,19 +232,15 @@ void constant_propagator_domaint::transform(
232232
/// handles equalities and conjunctions containing equalities
233233
bool constant_propagator_domaint::two_way_propagate_rec(
234234
const exprt &expr,
235-
const namespacet &,
235+
const namespacet &ns,
236236
const constant_propagator_ait *cp)
237237
{
238238
#ifdef DEBUG
239239
std::cout << "two_way_propagate_rec: " << format(expr) << '\n';
240-
#else
241-
(void)expr; // unused parameter
242240
#endif
243241

244242
bool change=false;
245243

246-
// this seems to be buggy at present
247-
#if 0
248244
if(expr.id()==ID_and)
249245
{
250246
// need a fixed point here to get the most out of it
@@ -265,14 +261,11 @@ bool constant_propagator_domaint::two_way_propagate_rec(
265261

266262
// two-way propagation
267263
valuest copy_values=values;
268-
assign_rec(copy_values, lhs, rhs, ns);
264+
assign_rec(copy_values, lhs, rhs, ns, cp);
269265
if(!values.is_constant(rhs) || values.is_constant(lhs))
270-
assign_rec(values, rhs, lhs, ns);
266+
assign_rec(values, rhs, lhs, ns, cp);
271267
change = values.meet(copy_values, ns);
272268
}
273-
#else
274-
(void)cp; // unused parameter
275-
#endif
276269

277270
#ifdef DEBUG
278271
std::cout << "two_way_propagate_rec: " << change << '\n';

0 commit comments

Comments
 (0)