FW: [commit: ghc] master: Fold constants during forward substitution in the Cmm mini-inliner (e97f298)
Simon Marlow
marlowsd at gmail.com
Mon Jun 6 05:17:26 CEST 2011
On 05/06/11 22:29, Simon Peyton-Jones wrote:
> Same questions here..
>
> Does this patch affect the new codegen path that Edward has been working on?
Right now, no. The Cmm optimiser is run by the native code generator,
so it gets used regardless which stg->cmm code generator we're using.
Long term we expect this to be subsumed by equivalent optimisations in
the new code generator path though.
> If not, do we need something similar in the new path?
>
> If the new path already has something similar (which I'm guessing it might), do we have a regression test that will show up whether or not it's working?
Johan has a test that compares assembly output I think - Johan, is it in
yet?
Cheers,
Simon
> Simon
>
>
> -----Original Message-----
> From: cvs-ghc-bounces at haskell.org [mailto:cvs-ghc-bounces at haskell.org] On Behalf Of Simon Marlow
> Sent: 01 June 2011 10:57
> To: cvs-ghc at haskell.org
> Subject: [commit: ghc] master: Fold constants during forward substitution in the Cmm mini-inliner (e97f298)
>
> Repository : ssh://darcs.haskell.org//srv/darcs/ghc
>
> On branch : master
>
> http://hackage.haskell.org/trac/ghc/changeset/e97f29804abdbf9b374aeb3661af340714ea1b60
>
>> ---------------------------------------------------------------
>
> commit e97f29804abdbf9b374aeb3661af340714ea1b60
> Author: Johan Tibell<johan.tibell at gmail.com>
> Date: Fri May 6 17:10:15 2011 +0200
>
> Fold constants during forward substitution in the Cmm mini-inliner
>
> This exposes new constants that can be propagated.
>
>> ---------------------------------------------------------------
>
> compiler/cmm/CmmOpt.hs | 25 +++++++++++++++++--------
> 1 files changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/compiler/cmm/CmmOpt.hs b/compiler/cmm/CmmOpt.hs
> index 1355cd2..69df4fb 100644
> --- a/compiler/cmm/CmmOpt.hs
> +++ b/compiler/cmm/CmmOpt.hs
> @@ -160,13 +160,13 @@ cmmMiniInline blocks = map do_inline blocks
>
> cmmMiniInlineStmts :: UniqFM Int -> [CmmStmt] -> [CmmStmt]
> cmmMiniInlineStmts uses [] = []
> -cmmMiniInlineStmts uses (stmt@(CmmAssign (CmmLocal (LocalReg u _)) expr@(CmmLit _)) : stmts)
> +cmmMiniInlineStmts uses (stmt@(CmmAssign (CmmLocal (LocalReg u _)) expr) : stmts)
> -- not used: just discard this assignment
> | Nothing<- lookupUFM uses u
> = cmmMiniInlineStmts uses stmts
>
> - -- used: try to inline at all the use sites
> - | Just n<- lookupUFM uses u
> + -- used (literal): try to inline at all the use sites
> + | Just n<- lookupUFM uses u, isLit expr
> =
> #ifdef NCG_DEBUG
> trace ("nativeGen: inlining " ++ showSDoc (pprStmt stmt)) $
> @@ -177,12 +177,21 @@ cmmMiniInlineStmts uses (stmt@(CmmAssign (CmmLocal (LocalReg u _)) expr@(CmmLit
> | otherwise ->
> stmt : cmmMiniInlineStmts (adjustUFM (\x -> x - m) uses u) stmts'
>
> -cmmMiniInlineStmts uses (stmt@(CmmAssign (CmmLocal (LocalReg u _)) expr : stmts))
> - -- not used at all: just discard this assignment
> - | Nothing<- lookupUFM uses u
> - = cmmMiniInlineStmts uses stmts
> + -- used (foldable to literal): try to inline at all the use sites
> + | Just n<- lookupUFM uses u,
> + CmmMachOp op es<- expr,
> + e@(CmmLit _)<- cmmMachOpFold op es
> + =
> +#ifdef NCG_DEBUG
> + trace ("nativeGen: inlining " ++ showSDoc (pprStmt stmt)) $
> +#endif
> + case lookForInlineLit u e stmts of
> + (m, stmts')
> + | n == m -> cmmMiniInlineStmts (delFromUFM uses u) stmts'
> + | otherwise ->
> + stmt : cmmMiniInlineStmts (adjustUFM (\x -> x - m) uses u) stmts'
>
> - -- used once: try to inline at the use site
> + -- used once (non-literal): try to inline at the use site
> | Just 1<- lookupUFM uses u,
> Just stmts'<- lookForInline u expr stmts
> =
>
>
>
> _______________________________________________
> Cvs-ghc mailing list
> Cvs-ghc at haskell.org
> http://www.haskell.org/mailman/listinfo/cvs-ghc
>
>
> _______________________________________________
> Cvs-ghc mailing list
> Cvs-ghc at haskell.org
> http://www.haskell.org/mailman/listinfo/cvs-ghc
More information about the Cvs-ghc
mailing list