Fix #3170: Allow coalescing of the same node during register allocation.
authorBen.Lippmeier@anu.edu.au <unknown>
Sat, 18 Apr 2009 08:22:53 +0000 (08:22 +0000)
committerBen.Lippmeier@anu.edu.au <unknown>
Sat, 18 Apr 2009 08:22:53 +0000 (08:22 +0000)
  The x86 code generator sometimes generates nop moves like
  movl %vI_a %vI_a, but we'll just ignore them for coalescing
  purposes instead of emitting an error. It shouldn't hurt anything.

compiler/utils/GraphOps.hs

index 8183e0b..17c14d0 100644 (file)
@@ -335,6 +335,9 @@ coalesceNodes aggressive triv graph (k1, k2)
        , not $ elementOfUniqSet kMin (nodeConflicts nMax)
        , not $ elementOfUniqSet kMax (nodeConflicts nMin)
 
+       -- can't coalesce the same node
+       , nodeId nMin /= nodeId nMax
+
        = coalesceNodes_merge aggressive triv graph kMin kMax nMin nMax
 
        -- don't do the coalescing after all
@@ -350,9 +353,6 @@ coalesceNodes_merge aggressive triv graph kMin kMax nMin nMax
        | not (isNothing (nodeColor nMin) && isNothing (nodeColor nMax))
        = error "GraphOps.coalesceNodes: can't coalesce colored nodes."
 
-       | nodeId nMin == nodeId nMax
-       = error "GraphOps.coalesceNodes: can't coalesce the same node."
-
        ---
        | otherwise
        = let