8000 Deterministic order for CSE parameters based on binding times by bclement-ocp · Pull Request #4234 · oxcaml/oxcaml · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Deterministic order for CSE parameters based on binding times #4234

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bclement-ocp
Copy link
Contributor

This patch ensures that the cse_param variables introduced by the CSE pass are introduced in a stable order that does not depend on the Int_ids assigned to variables.

This helps making comparisons between different runs (e.g. with different options) using the flambda2-compare library.

The order is determined lexicographically depending on the primitive under consideration and its arguments, which are guaranteed to be in scope in the target environment (see cse_with_eligible_lhs). The order for the argument uses the new stable_compare_simples function which is a total order on Simple.t values defined in a given typing environment, which coincides with the binding time order and does not depend on Int_ids hashing.

This patch ensures that the `cse_param` variables introduced by the CSE
pass are introduced in a stable order that does not depend on the
`Int_ids` assigned to variables.

This helps making comparisons between different runs (e.g. with
different options) using the `flambda2-compare` library.

The order is determined lexicographically depending on the primitive
under consideration and its arguments, which are guaranteed to be in
scope in the target environment (see `cse_with_eligible_lhs`). The order
for the argument uses the new `stable_compare_simples` function which
is a total order on `Simple.t` values defined in a given typing
environment, which coincides with the binding time order and does not
depend on `Int_ids` hashing.
@bclement-ocp bclement-ocp requested a review from lthls June 30, 2025 09:33
@bclement-ocp bclement-ocp added the flambda2 Prerequisite for, or part of, flambda2 label Jun 30, 2025
Copy link
Contributor
@lthls lthls left a comment

Choose a reason for hiding this comment

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

The PR looks correct, but I'm wondering if you considered having a version of Flambda_primitive.compare that is generic on the simple comparison primitive ?
This would avoid having what is essentially a copy of Flambda_primitive.compare in Common_subexpression_elimination.

@bclement-ocp
Copy link
Contributor Author

I got confused by that file, to be honest. Will do.

@bclement-ocp bclement-ocp requested a review from lthls June 30, 2025 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flambda2 Prerequisite for, or part of, flambda2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0