Skip to content
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

[PIR] Don't generate 'fixBy' if you don't need to #5954

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions plutus-core/plutus-ir/src/PlutusIR/Compiler/Recursion.hs
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,16 @@ mkFixpoint bs = do
name <- liftQuote $ toProgramName fixByKey
let (fixByTerm, fixByType) = Function.fixByAndType
pure (PLC.Def (PLC.VarDecl noProvenance name (noProvenance <$ fixByType)) (noProvenance <$ fixByTerm, Strict), mempty)
fixBy <- lookupOrDefineTerm p0 fixByKey mkFixByDef
Unisay marked this conversation as resolved.
Show resolved Hide resolved

let mkFixNDef = do
name <- liftQuote $ toProgramName fixNKey
let ((fixNTerm, fixNType), fixNDeps) =
if arity == 1
then (Function.fixAndType, mempty)
((fixNTerm, fixNType), fixNDeps) <-
if arity == 1
then pure (Function.fixAndType, mempty)
-- fixN depends on fixBy
else (Function.fixNAndType arity (void fixBy), Set.singleton fixByKey)
else do
fixBy <- lookupOrDefineTerm p0 fixByKey mkFixByDef
pure (Function.fixNAndType arity (void fixBy), Set.singleton fixByKey)
pure (PLC.Def (PLC.VarDecl noProvenance name (noProvenance <$ fixNType)) (noProvenance <$ fixNTerm, Strict), fixNDeps)
fixN <- lookupOrDefineTerm p0 fixNKey mkFixNDef

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,38 @@
1.1.0
[
[
(lam s_1650 [ s_1650 s_1650 ])
(lam s_1608 [ s_1608 s_1608 ])
(lam
s_1651
s_1609
(lam
x_1652
x_1610
[
(lam
factorial_1653
factorial_1611
[
[
[
[
(force (builtin ifThenElse))
[ [ (builtin equalsInteger) (con integer 0) ] x_1652 ]
[ [ (builtin equalsInteger) (con integer 0) ] x_1610 ]
]
(lam u_1654 (con integer 1))
(lam u_1612 (con integer 1))
]
(lam
u_1655
u_1613
[
[ (builtin multiplyInteger) x_1652 ]
[ (builtin multiplyInteger) x_1610 ]
[
factorial_1653
[ [ (builtin subtractInteger) x_1652 ] (con integer 1) ]
factorial_1611
[ [ (builtin subtractInteger) x_1610 ] (con integer 1) ]
]
]
)
]
(con unit ())
]
)
[ s_1651 s_1651 ]
[ s_1609 s_1609 ]
]
)
)
Expand Down