-
Notifications
You must be signed in to change notification settings - Fork 273
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
Use adjust_float_expression in simplify #2076
Conversation
@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.
8da4c69
to
651d41f
Compare
There was a problem hiding this 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, |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Closing for now as per @tautschnig comments this seems like the wrong approach to take. I'll try moving |
This lets the simplifier rewrite generic arithmetic operations to their floating point equivalents, which can simplify floating point expressions respecting rounding mode.