[GHC] #5171: Misfeature of Cmm optimiser: no way to extract a branch of expression into a separate statement
GHC
cvs-ghc at haskell.org
Sat Jul 16 00:28:46 CEST 2011
#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 | Milestone:
Component: Compiler | Version: 7.0.3
Keywords: Cmm optimisation | Testcase:
Blockedby: | Difficulty:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: Runtime performance bug
---------------------------------+------------------------------------------
Description changed by igloo:
Old description:
> 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.
New description:
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#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list