36 | | The problem is that this is being passed as an argument to a function. In this case `runSTRep` (which is the function its being passed to) might help, but what is the general solution? |
37 | | |
38 | | In this case, inlining `runSTRep` helps a bit, as it decreases allocation to `+6.6%`. (Whether that is correct is quite dubious). But in order to propagate the CPR’ing to tabulate, it seems one needs to pass nested CPR information from a case scrunitee to its components. |
39 | | |
40 | | So I implement this, and now `tabulate` itself gets a CPR property, which comes from the second component of the `ST` action, as extracted by `runSTRep`. But we still do not retain the join-point-property, as the code that throws away the `ST` token is still there: |
41 | | {{{ |
42 | | case $wgo ww ipv of _ [Occ=Dead] { (# ww3, ww4, ww5, ww6, ww7 #) -> |
43 | | (# ww4, ww5, ww6, ww7 #) |
44 | | }}} |
45 | | |
46 | | At that point I am running out of ideas. |
47 | | |
| 36 | The problem is that this is being passed as an argument to a function (in this case `runSTRep`), and there is not much that can be done about this at this point. |
68 | | Inlining `snd` does not help a lot: |
69 | | {{{ |
70 | | f a x = case a of |
71 | | True -> case foo of b -> |
72 | | let go 0 = (1,(2,3)) |
73 | | go n = go (n-1) |
74 | | in case (go b) of (x,y) -> y |
75 | | False -> undefined |
76 | | }}} |
77 | | still turns into |
78 | | {{{ |
79 | | f a x = case a of |
80 | | True -> case foo of b -> snd $ |
81 | | let $wgo 0 = (# 1, 2, 3 #) |
82 | | $wgo n = go (n-1) |
83 | | in case $wgo b of (# a, b, c #) -> (b,c) |
84 | | False -> undefined |
85 | | }}} |
86 | | Furthermore allowing CPR information to flow from scrunitee to bound variables gives `f` a CPR property (which is good), but does not solve the problem. |
87 | | {{{ |
88 | | $wf a x = case a of |
89 | | True -> case foo of b -> snd $ |
90 | | let $go 0 = (# 1, 2, 3 #) |
91 | | $go n = go (n-1) |
92 | | in case $go b of (# a, b, c #) -> (# b, c #) |
93 | | False -> undefined |
94 | | }}} |
95 | | |