-
Notifications
You must be signed in to change notification settings - Fork 0
CSE of involutions #410
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
base: flambda2.0-stable
Are you sure you want to change the base?
CSE of involutions #410
Conversation
0edc1c7
to
3d53fb6
Compare
The provided example is not completely simplified. The boxed integer and float cases do not trigger the CSE.
When looking for the second negation in the CSE environment, it is looking for (assuming no renaming) Should I fix it here ? I'm a bit worried that it might cause some other problems that I don't foresee. Otherwise, that might just be a new case to add to the |
@chambart This seems like a bug we should fix, I think. The CSE code was supposed to be doing the appropriate canonicalisation to avoid this sort of problem. Can you have a look? |
I added abefc4a to update the primitive with the simplified arguments before applying CSE. Otherwise I added a test for involutions. It does not work right now because of the max inlining depth that prevents the involution function from being inlined. So it is here but I didn't activate it for the CI yet. |
Can't the test specify in its config a custom inlining depth to pass through to the ocamlopt cli ? |
|
It is disabled right now, so this will have to wait for the rec info things to be finished ocaml/middle_end/flambda/inlining/inlining_state.ml Lines 38 to 42 in 6e33b8f
|
@@ -47,12 +48,12 @@ let try_cse dacc ~original_prim ~simplified_args_with_tys ~min_name_mode | |||
if not (Name_mode.equal min_name_mode Name_mode.normal) then Not_applied dacc | |||
else | |||
let result_var = VB.var result_var in | |||
match apply_cse dacc ~original_prim with | |||
let args = List.map fst simplified_args_with_tys in | |||
match apply_cse dacc ~original_prim:(P.update_args original_prim args) with |
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.
Hmm. Don't we want to rebind original_prim
to the version with the simplified arguments? Otherwise, further down, in the None
case we'll end up storing the primitive in the environment with the un-simplified arguments.
| exception Not_found -> None | ||
with | ||
| exception Not_found -> | ||
(* CR pchambart: is this really reachable ? Should this be a fatal_error ? *) |
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 probably should be a fatal error, let's try.
This allows simplifying into the identity