-
Notifications
You must be signed in to change notification settings - Fork 481
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
Add commuteConst
to simplifier pass.
#5360
Conversation
562d229
to
78e11c9
Compare
commuteConst
to simplifier pass.
caa5707
to
971003f
Compare
971003f
to
b6d90f6
Compare
dd06e77
to
1967033
Compare
plutus-core/plutus-ir/src/PlutusIR/Transform/CommuteFnWithConst.hs
Outdated
Show resolved
Hide resolved
plutus-core/plutus-ir/src/PlutusIR/Transform/CommuteFnWithConst.hs
Outdated
Show resolved
Hide resolved
plutus-core/plutus-ir/src/PlutusIR/Transform/CommuteFnWithConst.hs
Outdated
Show resolved
Hide resolved
plutus-core/plutus-ir/src/PlutusIR/Transform/CommuteFnWithConst.hs
Outdated
Show resolved
Hide resolved
SerialiseData -> False | ||
MkPairData -> False | ||
MkNilData -> False | ||
MkNilPairData -> False |
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.
I'm unsure, but I think given we're listing some exceptions, this could reasonably have a _ -> False
case.
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.
I also prefer the catch-all case. It actually makes it easier to catch mistakes.
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.
What I'm trying to do is to force us to add a case here whenever we add a new DefaultFun
. Otherwise, any new builtins will just be false, because we're unlikely to remember this unless the compiler reminds us. Of course, not remembering is not the end of the world because we just won't commute, but I think it makes sense to add any upcoming commutative functions in here so that the optimization will apply.
Also, I generally don't like catchall for this reason - things just work, but maybe not as you intended!
plutus-core/plutus-ir/src/PlutusIR/Transform/CommuteFnWithConst.hs
Outdated
Show resolved
Hide resolved
|
||
commuteFnWithConst :: forall tyname name uni fun a. Typeable fun => | ||
Term tyname name uni fun a -> Term tyname name uni fun a | ||
commuteFnWithConst = case eqT @fun @DefaultFun of |
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.
I thought we decided we were going to take it as a parameter like InlineHints
?
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.
I don't love this at all: it just means it can't work for anything except DefaultFun
.
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.
I thought we decided we were going to take it as a parameter like InlineHints?
I think that's what you proposed rather than what we decided 😂
That would require adding additional parameters to a number of functions. It does make it work with other fun
s than DefaultFun
, but given we aren't planning to have anything other than DefaultFun
anytime soon, I'm inclined to say not to optimize prematurely.
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.
1967033
to
9a93b5c
Compare
9a93b5c
to
4d3c797
Compare
Doing this in PIR in case we want to do CSE in PIR.
Pre-submit checklist: