-
Notifications
You must be signed in to change notification settings - Fork 273
Refine recursive calls within the simplifier #5764
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
Refine recursive calls within the simplifier #5764
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #5764 +/- ##
===========================================
+ Coverage 74.44% 74.49% +0.04%
===========================================
Files 1446 1447 +1
Lines 157778 157768 -10
===========================================
+ Hits 117456 117527 +71
+ Misses 40322 40241 -81
Continue to review full report at Codecov.
|
73d4c56
to
29225f0
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.
Yes but...
I believe this PR is a correct implementation of what it claims and is one way of improving the code; this is definitely faster than redoing the dispatch when the ID is known.
But... I'm not sure it's the only way of improving it. This makes it harder to implement solutions where simplify_node
is caching or enforces some kind of sharing-aware graph visit rather than potentially exponential recursion. I don't have the bandwidth to do anything like that at the moment (I don't even know if it is a good / widely accepted idea) but I wouldn't want to make it harder than it already is.
rewritten_op.where() = simplify_node(rewritten_op.where()); | ||
return std::move(rewritten_op); | ||
return exists_exprt{op_as_forall.symbol(), | ||
simplify_not(not_exprt(op_as_forall.where()))}; |
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.
Nice!
I agree that it may be a good idea to always go through |
Agreed; it should be one way or the other. As I am not an "owner" for this area of code and don't have time to work on it... I don't feel like I should have a strong say. I think this is an improvement over the current state-of-affairs and until we have someone who can do something fancy (graph traversal, caching, etc.) with |
29225f0
to
23afd4e
Compare
23afd4e
to
3101ba7
Compare
1) When we know the id of an expression, use the corresponding simplify_* method rather than the generic simplify_node. 2) Avoid simplify_rec when all operands have been simplified already. 3) Don't call simplify_rec (or simplify_node) when there is nothing to simplify. Fixes: diffblue#4988
3101ba7
to
af08918
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.
Yes, this makes sense to call the right case directly when you already know which case it is going to be.
method rather than the generic simplify_node.
simplify.
Fixes: #4988