diff --git a/compiler/nativeGen/RegSpillCost.hs b/compiler/nativeGen/RegSpillCost.hs index e639c67b601c2fbddb620c26214619dc2620f422..d987937102570cac45d66d069e1c232aa33087c8 100644 --- a/compiler/nativeGen/RegSpillCost.hs +++ b/compiler/nativeGen/RegSpillCost.hs @@ -132,7 +132,7 @@ chooseSpill -> Reg chooseSpill info graph - = let cost = spillCost info graph + = let cost = spillCost_length info graph node = minimumBy (\n1 n2 -> compare (cost $ nodeId n1) (cost $ nodeId n2)) $ eltsUFM $ graphMap graph @@ -177,14 +177,14 @@ chooseSpill info graph -- Without live range splitting, its's better to spill from the outside in so set the cost of very -- long live ranges to zero -- - -spillCost +{- +spillCost_chaitin :: SpillCostInfo -> Graph Reg RegClass Reg -> Reg -> Float -spillCost info graph reg +spillCost_chaitin info graph reg -- Spilling a live range that only lives for 1 instruction isn't going to help -- us at all - and we definately want to avoid trying to re-spill previously -- inserted spill code. @@ -200,6 +200,21 @@ spillCost info graph reg | otherwise = fromIntegral (uses + defs) / fromIntegral (nodeDegree graph reg) where (_, defs, uses, lifetime) = fromMaybe (reg, 0, 0, 0) $ lookupUFM info reg +-} + +-- Just spill the longest live range. +spillCost_length + :: SpillCostInfo + -> Graph Reg RegClass Reg + -> Reg + -> Float + +spillCost_length info _ reg + | lifetime <= 1 = 1/0 + | otherwise = 1 / fromIntegral lifetime + where (_, _, _, lifetime) + = fromMaybe (reg, 0, 0, 0) $ lookupUFM info reg + lifeMapFromSpillCostInfo :: SpillCostInfo -> UniqFM (Reg, Int) diff --git a/compiler/utils/GraphColor.hs b/compiler/utils/GraphColor.hs index 46bf384bd6d244706d21e9ae4244d537b7f4ec80..09fc5c26fa3c938c5c28372af79cb23879ef7ff4 100644 --- a/compiler/utils/GraphColor.hs +++ b/compiler/utils/GraphColor.hs @@ -55,7 +55,7 @@ colorGraph iterative colors triv spill graph0 -- coalescing stage at the front. (graph_coalesced, kksCoalesce1) = if not iterative - then coalesceGraph False triv graph0 + then coalesceGraph True triv graph0 else (graph0, []) -- run the scanner to slurp out all the trivially colorable nodes