Skip to content

RequirementMachine: Better rule deletion heuristic #39772

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

Merged
merged 4 commits into from
Oct 15, 2021

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Oct 15, 2021

To match the GSB's same-type requirement minimization algorithm, prefer to mark "less canonical" rules as redundant, by defining a linear order on rules that first compares the LHS and then the RHS. This replaces the previous heuristic which simply preferred to delete lower-numbered rules.

Also, the GSB's "connected components" algorithm has special behavior with concrete type requirements that we need to simulate. I already implemented the part where if you start with:

A == B, A == C, A == D

You get:

A == B, B == C, C == D

However we need to handle concrete type requirements when collecting these "connected components" as well, so if you start with

A == B, A == C, A == D, A == Int

You get:

A == Int, B == Int, D == Int

And not:

A == B, B == C, C == D, A == Int

@slavapestov slavapestov force-pushed the rqm-connected-components branch from 5bf6ddd to 9e7ee16 Compare October 15, 2021 18:29
…al rules

Instead of deleting lower numbered rules, compare the LHS, and if they're
equal, compare the RHS, then use that to pick the rule to delete.
@slavapestov slavapestov force-pushed the rqm-connected-components branch from 9e7ee16 to cd86924 Compare October 15, 2021 19:13
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov slavapestov merged commit d6954c0 into swiftlang:main Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant