-
Notifications
You must be signed in to change notification settings - Fork 11
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
Smarter helper rules #682
Draft
yihozhang
wants to merge
7
commits into
main
Choose a base branch
from
yihozhang-smaller-egraph
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Smarter helper rules #682
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
803957f
first attemp
yihozhang d01478b
test
yihozhang c28d700
small fix
yihozhang bea0e22
fix subtuple generator
yihozhang db81b98
fix test
yihozhang 421d256
revert memory.rs change
yihozhang c91f879
big regression it seems?
yihozhang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,13 +41,16 @@ | |
; Make Concats right-deep | ||
(rewrite (Concat (Concat a b) c) | ||
(Concat a (Concat b c)) | ||
:subsume | ||
:ruleset always-run) | ||
; Simplify Concat's with empty | ||
(rewrite (Concat (Empty ty ctx) x) | ||
x | ||
:subsume | ||
:ruleset always-run) | ||
(rewrite (Concat x (Empty ty ctx)) | ||
x | ||
:subsume | ||
:ruleset always-run) | ||
|
||
; Make a tuple that is a sub-range of another tuple | ||
|
@@ -56,36 +59,29 @@ | |
|
||
(rewrite (SubTuple expr x 0) | ||
(Empty ty ctx) | ||
:subsume | ||
:when ((HasArgType expr ty) (ContextOf expr ctx)) | ||
:ruleset always-run) | ||
|
||
(rewrite (SubTuple expr x 1) | ||
(Single (Get expr x)) | ||
:subsume | ||
:ruleset always-run) | ||
|
||
(rewrite (SubTuple expr a b) | ||
(Concat (Single (Get expr a)) (SubTuple expr (+ a 1) (- b 1))) | ||
:subsume | ||
:when ((> b 1)) | ||
:ruleset always-run) | ||
|
||
; Also figure out what existing expressions are subtuples of other things | ||
; this helps remove concat layers | ||
(rule ((Get expr i)) | ||
((union (Single (Get expr i)) | ||
(SubTuple expr i 1))) | ||
; ;; This rule makes sure every tuple can be | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is actually unnecessary because we are already generating gets for every "important" tuple. Removed in my new PRs. |
||
; ;; normalized as a list of (Concat (Single e1) (Concat (Single e2) ...)) | ||
(rewrite e (SubTuple e 0 len) | ||
:when ((tuples-to-generate-get-for e) | ||
(HasType e (TupleT t)) | ||
(= len (TypeList-length t))) | ||
:ruleset always-run) | ||
|
||
(rewrite (Concat (SubTuple expr a b) | ||
(SubTuple expr (+ a b) c)) | ||
(SubTuple expr a (+ b c)) | ||
:ruleset always-run) | ||
;; a subtuple which is the entire tuple is the tuple itself | ||
;; this removes unecessary layers of concat | ||
(rewrite (SubTuple expr 0 len) | ||
expr | ||
:when ((= len (tuple-length expr))) | ||
:ruleset always-run) | ||
|
||
; Helper functions to remove one element from a tuple or type list | ||
; tuple idx | ||
(function TupleRemoveAt (Expr i64) Expr :unextractable) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The old TypeList-suffix based implementation is quadratic in the size of the list (which easily goes to 20+)