[GHC] #10120: Unnecessary code duplication from case analysis

GHC ghc-devs at haskell.org
Fri Feb 27 05:34:56 UTC 2015


#10120: Unnecessary code duplication from case analysis
-------------------------------------+-------------------------------------
        Reporter:  bgamari           |                   Owner:
            Type:  bug               |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.10.1-rc2
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  Runtime           |  Unknown/Multiple
  performance bug                    |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:                    |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by bgamari):

 Interestingly enough GHC 7.8 is a bit more conservative in how it inlines:
 while it still produces the unneccessarily branch-y case expression, it at
 least doesn't inline `do_something` into each branch,

 {{{#!hs
 $wa_r3Fx =
   \ ww_s3EZ w_s3EW ->
     let {
       $j_s1xX
       $j_s1xX =
         \ _ ->
           hPutStr2
             stdout
             (case ww_s3EZ of ds1_a1xG {
                __DEFAULT -> : shows21 ($wshowLitChar ds1_a1xG lvl_r3Fw);
                '\'' -> shows20
              })
             True
             w_s3EW } in
     case ww_s3EZ of _ {
       __DEFAULT -> (# w_s3EW, () #);
       '$' -> $j_s1xX void#;
       '&' -> $j_s1xX void#;
       ...
       '_' -> $j_s1xX void#;
       '~' -> $j_s1xX void#
 }}}

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


More information about the ghc-tickets mailing list