Skip to content

Commit a726c7a

Browse files
committed
constant_evaluator - only simplify and reeval operands if TOP
1 parent 3092e7b commit a726c7a

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/analyses/variable-sensitivity/abstract_value_object.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -255,19 +255,20 @@ class constants_evaluator
255255
auto lhs_value = eval_constant(op);
256256

257257
// do not give up if a sub-expression is not a constant,
258-
// because the whole expression may still be simplified in some cases
259-
expr.operands().push_back(lhs_value.is_nil() ? op : lhs_value);
260-
}
261-
262-
exprt simplified = simplify_expr(expr, ns);
263-
for(const exprt &op : simplified.operands())
264-
{
265-
auto lhs_value = eval_constant(op);
266258
if(lhs_value.is_nil())
267-
return top(simplified.type());
259+
{
260+
exprt simplified_op = simplify_expr(op, ns);
261+
if(simplified_op.is_not_nil())
262+
lhs_value = eval_constant(simplified_op);
263+
if(lhs_value.is_nil())
264+
return top(expr.type());
265+
}
266+
267+
expr.operands().push_back(lhs_value);
268268
}
269269

270270
// the expression is fully simplified
271+
exprt simplified = simplify_expr(expr, ns);
271272
return std::make_shared<constant_abstract_valuet>(
272273
simplified, environment, ns);
273274
}

0 commit comments

Comments
 (0)