You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Save the following GRIN program in src.grin and then optimise it with grin src.grin --optimize.
grinMain =
u.box <- pure (CUnit)
u.thunk <- store u.box
w.box <- pure (Ffoo u.thunk u.thunk)
w.thunk <- store w.box
foo $ w.thunk u.thunk
foo a.thunk b.thunk =
(Ffoo c.thunk d.thunk) <- fetch a.thunk
(CUnit) <- fetch d.thunk
out.prim_int <- pure 0
_prim_int_print $ out.prim_int
Optimisation will fail with output:
PipelineStep: Optimize PHASE #1
PipelineStep: T BindNormalisation had effect: None (0.001351 ms)
PipelineStep: T SimpleDeadFunctionElimination had effect: ExpChanged (0.001667 ms)
PipelineStep: SaveGrin (Rel "SimpleDeadFunctionElimination.grin") (0.311913 ms)
PipelineStep: T SimpleDeadParameterElimination had effect: ExpChanged (0.001111 ms)
PipelineStep: SaveGrin (Rel "SimpleDeadParameterElimination.grin") (0.223380 ms)
error after SimpleDeadParameterElimination:
undefined variable: d.thunk
illegal code
(Note: SimpleDeadFunctionElimination reports had effect: ExpChanged yet its output is identical to the original program.)
The SimpleDeadParameterElimination step eliminates b.thunk and d.thunk, but (CUnit) <- fetch d.thunk is left intact.
Below is .output/002.SimpleDeadParameterElimination
grinMain =
u.box <- pure (CUnit)
u.thunk <- store u.box
w.box <- pure (Ffoo u.thunk)
w.thunk <- store w.box
foo $ w.thunk
foo a.thunk =
(Ffoo c.thunk) <- fetch a.thunk
(CUnit) <- fetch d.thunk
out.prim_int <- pure 0
_prim_int_print $ out.prim_int
Linting src.grin with --lint shows that the program is correct, so this appears to be due to either a bug in the linter, or a bug in SimpleDeadParameterElimination.
This problem initially arose when I was trying to optimise a generated program (which is also correct according to the linter).
That generated program is 282 lines long, so I opted to hand-write a minimal example instead.
The text was updated successfully, but these errors were encountered:
Z-snails
added a commit
to Z-snails/Idris2-Grin
that referenced
this issue
Mar 15, 2021
- Changed back to 'CPS' (passes the variable the final result is in)
- Added a few more primitives
- Fixed variable indexes in primitive functions
- Moved some functions to Prims.idr beacause they're needed there
Unfortunately the GRIN compiler doesn't work properly yet
see (grin-compiler/grin#115) for details
This issue hasn't seen any interaction since last July so I have no idea if it will be fixed
But I will have a look at the code to see if I can fix it at some point
GRIN Version:
310fdc3a184353049213d28c84980345d1ff66fd
(currentmaster
)Save the following GRIN program in
src.grin
and then optimise it withgrin src.grin --optimize
.Optimisation will fail with output:
(Note:
SimpleDeadFunctionElimination
reportshad effect: ExpChanged
yet its output is identical to the original program.)The
SimpleDeadParameterElimination
step eliminatesb.thunk
andd.thunk
, but(CUnit) <- fetch d.thunk
is left intact.Below is
.output/002.SimpleDeadParameterElimination
Linting
src.grin
with--lint
shows that the program is correct, so this appears to be due to either a bug in the linter, or a bug inSimpleDeadParameterElimination
.This problem initially arose when I was trying to optimise a generated program (which is also correct according to the linter).
That generated program is 282 lines long, so I opted to hand-write a minimal example instead.
The text was updated successfully, but these errors were encountered: