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 |
| 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.
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.
This probably should be a fatal error, let's try.
This allows simplifying into the identity