Skip to content

Use adjust_float_expression in simplify #2076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

hannes-steffenhagen-diffblue
Copy link
Contributor

This lets the simplifier rewrite generic arithmetic operations to their floating point equivalents, which can simplify floating point expressions respecting rounding mode.

@hannes-steffenhagen-diffblue
Copy link
Contributor Author

@martin-cs This has the floating point changes we were talking about last week. Can you please check if this is in line with what you were thinking? This doesn't have any goto-analyzer specific things in it (like trying to use different rounding modes), but I believe this is an independent step we can use as a starting point.

This necessitates moving the code from symex
to util.
Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few smaller issues, but mainly I'm concerned about the use of the initial value as found in the symbol table. This value, if still in line with a program's semantics, should be forwarded via constant propagation.

}

void adjust_float_expressions(
goto_functionst::goto_functiont &goto_function,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file will need to be split up, those functions can't live in util/ as they have dependencies on goto-programs.

else if(expr.id()==ID_mod)
result=simplify_mod(expr) && result;
if(expr.type().id() == ID_floatbv)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add braces here.

@@ -2284,11 +2303,35 @@ bool simplify_exprt::simplify_node(exprt &expr)
else if(expr.id()==ID_power)
result=simplify_power(expr) && result;
else if(expr.id()==ID_plus)
result=simplify_plus(expr) && result;
if(expr.type().id() == ID_floatbv)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Braces, please.

else if(expr.id()==ID_minus)
result=simplify_minus(expr) && result;
if(expr.type().id() == ID_floatbv)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Braces, please.

else if(expr.id()==ID_mult)
result=simplify_mult(expr) && result;
if(expr.type().id() == ID_floatbv)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Braces, please.

if(expr.type().id() == ID_floatbv)
{
adjust_float_expressions(expr, ns);
result = simplify_rec(expr);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing && result (the same in all the other edits below)

}
else
{
result = simplify_div(expr) && result;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not move the if(expr.type().id() == ID_floatbv) inside simplify_div etc?

to_symbol_expr(attached_rounding_mode).get_identifier(),
p_rounding_sym))
{
attached_rounding_mode = p_rounding_sym->value;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is using the initial value justified? It may, after all, change during program execution?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was just me misunderstanding how namespacet is used, this indeed seems to be the wrong thing to do here.

I was thinking I could somehow do symbol evaluation in simplify_expr, but it seems that this will have to be done outside of it.

@hannes-steffenhagen-diffblue
Copy link
Contributor Author

hannes-steffenhagen-diffblue commented Apr 17, 2018

Closing for now as per @tautschnig comments this seems like the wrong approach to take. I'll try moving adjust_float_expressions into goto-programs instead, and do the call in goto-analyzer (the whole point of this is to improve the handling of floats by goto-analayzer)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants