#5171: Misfeature of Cmm optimiser: no way to extract a branch of expression into a separate statement ---------------------------------+------------------------------------------ Reporter: rtvd | Owner: Type: feature request | Status: new Priority: normal | Component: Compiler Version: 7.0.3 | Keywords: Cmm optimisation Testcase: | Blockedby: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: Runtime performance bug ---------------------------------+------------------------------------------ AFAIK, optimisations in Cmm are performed using cmmMachOpFold. However, this function is pure and does not allow detaching a branch of expression in order to make sure that it is executed only once.
Let's say we have (Op1 arg1 arg2) and we want to transform it to (Op2 arg1 (Op3 arg2 arg1)). Doing this would mean that arg1 would be computed more than once. Instead, the following should be possible: arg1_reg <- arg1 (Op2 arg1_reg (Op3 arg2 arg1_reg)) The lack of this feature already stops one of optimisations from happening in most cases. See: CmmReg _ <- x -> -- We duplicate x below, hence require -- it is a reg. FIXME: remove this restriction. in CmmOpt.hs. There is a number of other useful optimisations which can be implemented only with this feature available. -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5171> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs