Add and use seqBitmap when constructing SRTs
authorIan Lynagh <igloo@earth.li>
Wed, 27 Feb 2008 14:45:05 +0000 (14:45 +0000)
committerIan Lynagh <igloo@earth.li>
Wed, 27 Feb 2008 14:45:05 +0000 (14:45 +0000)
This roughly halves memory usage when compiling
    module Foo where

    foo :: Double -> Int
    foo x | x == 1 = 1
    ...
    foo x | x == 500 = 500
without optimisation.

compiler/codeGen/Bitmap.hs
compiler/simplStg/SRT.lhs

index 7ee78a9..3b363fd 100644 (file)
@@ -16,7 +16,8 @@
 module Bitmap ( 
        Bitmap, mkBitmap,
        intsToBitmap, intsToReverseBitmap,
 module Bitmap ( 
        Bitmap, mkBitmap,
        intsToBitmap, intsToReverseBitmap,
-       mAX_SMALL_BITMAP_SIZE
+       mAX_SMALL_BITMAP_SIZE,
+       seqBitmap,
   ) where
 
 #include "HsVersions.h"
   ) where
 
 #include "HsVersions.h"
@@ -24,6 +25,7 @@ module Bitmap (
 
 import SMRep
 import Constants
 
 import SMRep
 import Constants
+import Util
 
 import Data.Bits
 
 
 import Data.Bits
 
@@ -85,3 +87,6 @@ mAX_SMALL_BITMAP_SIZE :: Int
 mAX_SMALL_BITMAP_SIZE  | wORD_SIZE == 4 = 27
                       | otherwise      = 58
 
 mAX_SMALL_BITMAP_SIZE  | wORD_SIZE == 4 = 27
                       | otherwise      = 58
 
+seqBitmap :: Bitmap -> a -> a
+seqBitmap = seqList
+
index 57c638d..5618cb1 100644 (file)
@@ -25,7 +25,7 @@ import Id             ( Id )
 import VarSet
 import VarEnv
 import Maybes          ( orElse, expectJust )
 import VarSet
 import VarEnv
 import Maybes          ( orElse, expectJust )
-import Bitmap          ( intsToBitmap )
+import Bitmap
 
 #ifdef DEBUG
 import Outputable
 
 #ifdef DEBUG
 import Outputable
@@ -157,7 +157,7 @@ srtAlt table (con,args,used,rhs)
 constructSRT :: IdEnv Int -> SRT -> SRT
 constructSRT table (SRTEntries entries)
  | isEmptyVarSet entries = NoSRT
 constructSRT :: IdEnv Int -> SRT -> SRT
 constructSRT table (SRTEntries entries)
  | isEmptyVarSet entries = NoSRT
- | otherwise  = SRT offset len bitmap
+ | otherwise  = seqBitmap bitmap $ SRT offset len bitmap
   where
     ints = map (expectJust "constructSRT" . lookupVarEnv table) 
                (varSetElems entries)
   where
     ints = map (expectJust "constructSRT" . lookupVarEnv table) 
                (varSetElems entries)