[GHC] #9374: Investigate Static Argument Transformation

GHC ghc-devs at haskell.org
Tue Sep 16 13:10:57 UTC 2014


#9374: Investigate Static Argument Transformation
-------------------------------------+-------------------------------------
              Reporter:  jstolarek   |            Owner:
                  Type:  task        |           Status:  new
              Priority:  lowest      |        Milestone:
             Component:  Compiler    |          Version:  7.9
            Resolution:              |         Keywords:
      Operating System:              |     Architecture:  Unknown/Multiple
  Unknown/Multiple                   |       Difficulty:  Unknown
       Type of failure:              |       Blocked By:
  None/Unknown                       |  Related Tickets:
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Here's an example where SAT would be a big win.  See
 [http://www.haskell.org/pipermail/ghc-devs/2014-September/006332.html
 email thread].
 {{{
 scanr =
   \ @ a_akP @ a1_akQ f_ah8 b_ah9 eta_B1 ->
     letrec {
       go_amb
       go_amb =
         \ ds_amc eta1_Xa eta2_B2 eta3_Xc ->
           case ds_amc of _ {
             [] -> eta1_Xa eta2_B2 eta3_Xc;
             : y_amh ys_ami ->
               go_amb
                 ys_ami
                 (\ x_an9 eta4_Xj ->
                    let {
                      b'_ana
                      b'_ana = f_ah8 y_amh x_an9 } in
                    eta1_Xa b'_ana (: b'_ana eta4_Xj))
                 eta2_B2
                 eta3_Xc
           }; } in
     go_amb eta_B1 scanr1 b_ah9 (: b_ah9 ([]))
 }}}
 The 3rd and 4th arg to `go` are static, and since there is only one call
 to `go`, doing SAT would yield much better code by specialising `go` for
 the particular parameters:
 {{{
 scanr =
   \ @ a_akP @ a1_akQ f_ah8 b_ah9 eta_B1 ->
     let {
       listend
       listend = : b_ah9 ([])} in
     letrec {
       go_amb
       go_amb =
         \ ds_amc eta1_Xa  ->
           case ds_amc of _ {
             [] -> eta1_Xa b_ah9 listend;
             : y_amh ys_ami ->
               go_amb
                 ys_ami
                 (\ x_an9 eta4_Xj ->
                    let {
                      b'_ana
                      b'_ana = f_ah8 y_amh x_an9 } in
                    eta1_Xa b'_ana (: b'_ana eta4_Xj))
           }; } in
     go_amb eta_B1 scanr1
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9374#comment:13>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list