After desugaring we have this,
loop_a1aWv [Occ=LoopBreaker] :: Word8 -> a_a1aZq -> Builder
loop_a1aWv =
\ (s_a1aWp :: Word8) (n_a1aWq :: a_a1aZq) ->
case case s_a1aWp of _ [Occ=Dead] { __DEFAULT ->
case n_a1aWq of _ [Occ=Dead] { __DEFAULT -> False }
}
of _ [Occ=Dead] {
True -> undefined @ Builder
False ->
(\ _ [Occ=Dead, OS=OneShot] ->
case == @ a_a1aZq $dEq_a1aZr n_a1aWq (fromInteger @ a_a1aZq $dNum_a1aZs (__integer 0))
of _ [Occ=Dead] {
True -> mempty @ Builder $fMonoidBuilder
False ->
(\ _ [Occ=Dead, OS=OneShot] ->
<>
@ Builder
$fMonoidBuilder
(singleton
(+ @ Word8
$fNumWord8
s_a1aWp
(fromInteger @ Word8 $fNumWord8 (__integer 0))))
(<>
@ Builder
$fMonoidBuilder
(singleton
(+ @ Word8
$fNumWord8
s_a1aWp
(fromInteger @ Word8 $fNumWord8 (__integer 1))))
...
(<>
@ Builder
$fMonoidBuilder
(singleton
(+ @ Word8
$fNumWord8
s_a1aWp
(fromInteger
@ Word8
$fNumWord8
(__integer 15))))
(loop_a1aWv
(+ @ Word8
$fNumWord8
s_a1aWp
(fromInteger
@ Word8
$fNumWord8
(__integer 16)))
(- @ a_a1aZq
$dNum_a1aZs
n_a1aWq
(fromInteger
@ a_a1aZq
$dNum_a1aZs
(__integer 16))))))))))))))))))))
Which the gentle simplifier pass then turns into,
loop_a1aWv [Occ=LoopBreaker] :: Word8 -> Int -> Builder
[LclId, Arity=2, Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=NEVER}]
loop_a1aWv =
\ (s_a1aWp :: Word8) (n_a1aWq :: Int) ->
case case s_a1aWp of _ [Occ=Dead] { W8# ipv_s1b2m ->
case n_a1aWq of _ [Occ=Dead] { I# ipv_s1b2p -> False }
}
of _ [Occ=Dead] {
True -> undefined @ Builder
False ->
case eqInt n_a1aWq ($fNumInt_$cfromInteger (__integer 0))
of _ [Occ=Dead] {
True -> empty
False ->
<>
@ Builder
$fMonoidBuilder
(singleton
($fNumWord8_$c+ s_a1aWp ($fBitsWord8_$cfromInteger (__integer 0))))
(<>
@ Builder
$fMonoidBuilder
(singleton
($fNumWord8_$c+ s_a1aWp ($fBitsWord8_$cfromInteger (__integer 1))))
(<>
@ Builder
$fMonoidBuilder
(singleton
($fNumWord8_$c+
s_a1aWp
($fBitsWord8_$cfromInteger
(__integer 15))))
(loop_a1aWv
($fNumWord8_$c+
s_a1aWp
($fBitsWord8_$cfromInteger
(__integer 16)))
($fNumInt_$c-
n_a1aWq
($fNumInt_$cfromInteger
(__integer 16)))))))))))))))))));
So far, so good. The specializer then runs and levels are then added but not much changes.
Then comes the Result size of Float out(FOS {Lam = Just 0, Consts = True, OverSatApps = False})
pass, which floats out all of the __integer
literals up to the top
level, as well as the loop_a1aWv
lvl_s1b3j :: Integer
lvl_s1b3j = __integer 0
lvl_s1b3k :: Word8
lvl_s1b3k = $fBitsWord8_$cfromInteger lvl_s1b3j
lvl_s1b3l :: Integer
lvl_s1b3l = __integer 1
lvl_s1b3m :: Word8
lvl_s1b3m = $fBitsWord8_$cfromInteger lvl_s1b3l
...
loop_s1b3f [Occ=LoopBreaker] :: Word8 -> Int -> Builder
loop_s1b3f =
\ (s_a1aWp :: Word8) (n_a1aWq :: Int) ->
case case s_a1aWp of _ [Occ=Dead] { W8# ipv_s1b2m ->
case n_a1aWq of _ [Occ=Dead] { I# ipv_s1b2p -> False }
}
of _ [Occ=Dead] {
True -> undefined @ Builder
False ->
case eqInt n_a1aWq lvl_s1b3i of _ [Occ=Dead] {
True -> empty
False ->
<>
@ Builder
$fMonoidBuilder
(singleton ($fNumWord8_$c+ s_a1aWp lvl_s1b3k))
(<>
@ Builder
$fMonoidBuilder
(singleton ($fNumWord8_$c+ s_a1aWp lvl_s1b3m))
...
(<>
@ Builder
$fMonoidBuilder
(singleton
($fNumWord8_$c+ s_a1aWp lvl_s1b3O))
(loop_s1b3f
($fNumWord8_$c+ s_a1aWp lvl_s1b3Q)
($fNumInt_$c-
n_a1aWq lvl_s1b3S)))))))))))))))));
This is where the damage begins.
We then go through simplifier phase 2,
loop_s1b3f [Occ=LoopBreaker] :: Word8 -> Int -> Builder
[LclId,
Arity=2,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=NEVER}]
loop_s1b3f =
\ (s_a1aWp :: Word8) (n_a1aWq :: Int) ->
case s_a1aWp of _ [Occ=Dead] { W8# ipv_s1b2m ->
case n_a1aWq of _ [Occ=Dead] { I# ipv_s1b2p ->
case ipv_s1b2p of wild_X1n {
0 -> empty
__DEFAULT ->
append
(primBounded
(BP
16
((\ (ds2_d2mT :: (Word8, (Word8, (Word8, (Word8, (Word8, (Word8, (Word8, (Word8, (Word8, (Word8, (Word8, (Word8, (Word8, (Word8, (Word8, Word8))))))))))))))))
(op_a26r :: Ptr Word8)
(eta_B1 [OS=OneShot] :: State# RealWorld) ->
case ds2_d2mT of _ [Occ=Dead] { (x1_a26p, x2_a26q) ->
case op_a26r of _ [Occ=Dead] { Ptr a_a3G8 ->
case x1_a26p of _ [Occ=Dead] { W8# x_a3Gc ->
case writeWord8OffAddr# @ RealWorld a_a3G8 0 x_a3Gc eta_B1
of s2_a3Ge [OS=OneShot] { __DEFAULT ->
let {
a_s1bBk :: Addr#
[LclId, Unf=Unf{Src=<vanilla>, TopLvl=False, Value=False, ConLike=False, WorkFree=False, Expandable=True, Guidance=IF_ARGS [] 1 0}]
a_s1bBk = plusAddr# a_a3G8 1 } in
case x2_a26q of _ [Occ=Dead] { (x1_X2ag, x2_X2ai) ->
case x1_X2ag of _ [Occ=Dead] { W8# x_X3K9 ->
case writeWord8OffAddr# @ RealWorld a_s1bBk 0 x_X3K9 s2_a3Ge
of s2_X3Ke [OS=OneShot] { __DEFAULT ->
case x2_X2ai of _ [Occ=Dead] { (x1_X27d, x2_X27f) ->
let {
a_X3H0 :: Addr#
[LclId, Unf=Unf{Src=<vanilla>, TopLvl=False, Value=False, ConLike=False, WorkFree=False, Expandable=True, Guidance=IF_ARGS [] 1 0}]
a_X3H0 = plusAddr# a_s1bBk 1 } in
...
case x2_X28C of _ [Occ=Dead] { W8# x_X3Ii ->
case writeWord8OffAddr# @ RealWorld a_s1b4s 0 x_X3Ii s2_X3Ld
of s2_X3KP [OS=OneShot] { __DEFAULT ->
(# s2_X3KP, Ptr @ Word8 (plusAddr# a_s1b4s 1) #)
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}})
(W8# (narrow8Word# ipv_s1b2m),
(W8# (narrow8Word# (plusWord# ipv_s1b2m (__word 1))),
(W8# (narrow8Word# (plusWord# ipv_s1b2m (__word 2))),
(W8# (narrow8Word# (plusWord# ipv_s1b2m (__word 3))),
(W8# (narrow8Word# (plusWord# ipv_s1b2m (__word 4))),
(W8# (narrow8Word# (plusWord# ipv_s1b2m (__word 5))),
(W8# (narrow8Word# (plusWord# ipv_s1b2m (__word 6))),
(W8# (narrow8Word# (plusWord# ipv_s1b2m (__word 7))),
(W8# (narrow8Word# (plusWord# ipv_s1b2m (__word 8))),
(W8# (narrow8Word# (plusWord# ipv_s1b2m (__word 9))),
(W8# (narrow8Word# (plusWord# ipv_s1b2m (__word 10))),
(W8# (narrow8Word# (plusWord# ipv_s1b2m (__word 11))),
(W8# (narrow8Word# (plusWord# ipv_s1b2m (__word 12))),
(W8# (narrow8Word# (plusWord# ipv_s1b2m (__word 13))),
(W8# (narrow8Word# (plusWord# ipv_s1b2m (__word 14))),
W8#
(narrow8Word# (plusWord# ipv_s1b2m (__word 15)))))))))))))))))))
(loop_s1b3f
(W8# (narrow8Word# (plusWord# ipv_s1b2m (__word 16))))
(I# (-# wild_X1n 16)));
}}}
From this point forth the compiler seems stuck.
The phase 1 simplifier pass shuffles things around a bit, turning the
tuple of W8#
s above into a sphaghetti of let
s building up a tuple.
This persists through simplifier phase 0. The float inwards pass succeeds in pushing the
Call-arity analysis
Simplifier phase 0 [post-call-arity]
Demand analysis
Worker Wrapper binds
Simplifier 0 [post-worker-wrapper] turns the tuple-sphagetti into a
bunch of independent let
s outside the case tagToEnum# @ Bool (<# (minusAddr# dt1_dRV4 dt_dRV3) 16)
analysis. These bindings are shared by
both branches of this case
.
Levels added renders the Core quite clearly.
Float out(FOS {Lam = Just 0, Consts = True, OverSatApps = True})
CSE
Float inwards
Liberate case
Simplifier 0 [post-liberate-case]
SpecConstr
Simplifier 0 [final]