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
#13573 would have included one optimization which #16650, et seq., did not, namely the optimization of for-loops over integral ranges with steps other than 1 and -1 in resumable code computation expressions (like task). I figured I might as well record it here (cc @psfinaki).
It seems like it might be relatively straightforward to add this optimization now by wiring up the IntegralRange and mkOptimizedRangeLoop constructs exposed in #16650.
Supplement the existing match on IntegerForLoopExpr with another match on CompiledForEachExpr and IntegralRange:
{ phase1 = mkIntegerForLoop g (spFor, spTo, v, res1.phase1, style, res2.phase1, res3.phase1, m)
However, the existing optimization for for-loops over int32 ranges with steps of 1 or -1 doesn't always seem to kick in — in fact, I haven't been able to get it to kick in at all, even when using the syntax for n = start to finish do … instead of for n in start..finish do …. So figuring out why that is, and what the TAST actually looks like by the time it gets to LowerStateMachines.fs, might end up being the harder problem to solve.
The text was updated successfully, but these errors were encountered:
#13573 would have included one optimization which #16650, et seq., did not, namely the optimization of
for
-loops over integral ranges with steps other than1
and-1
in resumable code computation expressions (liketask
). I figured I might as well record it here (cc @psfinaki).It seems like it might be relatively straightforward to add this optimization now by wiring up the
IntegralRange
andmkOptimizedRangeLoop
constructs exposed in #16650.Supplement the existing match on
IntegerForLoopExpr
with another match onCompiledForEachExpr
andIntegralRange
:fsharp/src/Compiler/Optimize/LowerStateMachines.fs
Lines 485 to 486 in 5fd6800
There is an existing translation using
mkIntegerForLoop
; add a new one that usesmkOptimizedRangeLoop
:fsharp/src/Compiler/Optimize/LowerStateMachines.fs
Line 692 in 5fd6800
However, the existing optimization for
for
-loops overint32
ranges with steps of1
or-1
doesn't always seem to kick in — in fact, I haven't been able to get it to kick in at all, even when using the syntaxfor n = start to finish do …
instead offor n in start..finish do …
. So figuring out why that is, and what the TAST actually looks like by the time it gets toLowerStateMachines.fs
, might end up being the harder problem to solve.The text was updated successfully, but these errors were encountered: