[GHC] #14226: Common Block Elimination pass doesn't eliminate common blocks

GHC ghc-devs at haskell.org
Fri Sep 15 11:59:28 UTC 2017


#14226: Common Block Elimination pass doesn't eliminate common blocks
-------------------------------------+-------------------------------------
        Reporter:  bgamari           |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.4.1
       Component:  Compiler          |              Version:  8.2.1
  (CodeGen)                          |
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 OK, got it.  Yes, totally.  CBE should be insensitive to alpha-renaming of
 local register.

 One way to do this would be for the hashing function to be sensitive to
 binding sites.  Concretely, suppose that we had
 {{{
 hashInstrs :: HashEnv -> [Instruction] -> HashCode
 type HashEnv = (Map LocalReg HashCode, Int)
 }}}
 Now we could have
 {{{
 hashInstrs (env, next) (Load reg expr : instrs)
   = hashInstrs (extendEnv env reg next, next+1) instrs
     `hashPlus` hashExpr env expr

 ...

 hashExpr env (LocalReg r)
   | Just hc <- lookupEnv env r = hc
   | otherwise = hashLocalReg r  -- as now
 }}}
 The mapping tells what hashcode to use for a local register. We deBruijn-
 number all binding sites as we come across them, mapping them to 1, 2, 3,
 etc. Now we'll be insensitive to what name is chosen.

 I think we already have a function that, for an instruction, says what
 local regs it assigns to.

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


More information about the ghc-tickets mailing list