[commit: ghc] master: Fix a bug in CmmSink exposed by a recent optimisation (#7366) (c588395)

Simon Marlow <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/c588395719241c4b5756bd8d60dbf822915dfc5b

>---------------------------------------------------------------

commit c588395719241c4b5756bd8d60dbf822915dfc5b
Author: Simon Marlow <[email protected]>
Date:   Thu Oct 25 16:18:36 2012 +0100

    Fix a bug in CmmSink exposed by a recent optimisation (#7366)

>---------------------------------------------------------------

 compiler/cmm/CmmSink.hs |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/compiler/cmm/CmmSink.hs b/compiler/cmm/CmmSink.hs
index 9565fec..7553e37 100644
--- a/compiler/cmm/CmmSink.hs
+++ b/compiler/cmm/CmmSink.hs
@@ -384,6 +384,7 @@ tryToInline dflags live node assigs = go usages node [] assigs
                 -- usages of the regs on the RHS to 2.
 
         cannot_inline = skipped `regsUsedIn` rhs -- Note [dependent assignments]
+                        || l `elem` skipped
                         || not (okToInline dflags rhs node)
 
         occurs_once = not (l `elemRegSet` live)
@@ -415,6 +416,15 @@ tryToInline dflags live node assigs = go usages node [] assigs
 --
 -- For now we do nothing, because this would require putting
 -- everything inside UniqSM.
+--
+-- One more variant of this (#7366):
+--
+--   [ y = e, y = z ]
+--
+-- If we don't want to inline y = e, because y is used many times, we
+-- might still be tempted to inline y = z (because we always inline
+-- trivial rhs's).  But of course we can't, because y is equal to e,
+-- not z.
 
 addUsage :: UniqFM Int -> LocalReg -> UniqFM Int
 addUsage m r = addToUFM_C (+) m r 1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.