ran into this bug when compiling with the optimization flags:
-H10M -O -fvia-C -O2-for-C
"
NOTE: Simplifier still going after 4 iterations; bailing out.
NOTE: Simplifier still going after 4 iterations; bailing out.
panic! (the `impossible' happened):
getWorkerIdAndCons deQueueWhile{-r85,x-}{i}
Please report it as a compiler bug to [EMAIL PROTECTED]
"
here is the file it was trying to compile:
------------------------------------------------------------------------
module AddrQueue where
import LazyST
import Utils
import Hawk
type AddrQueue s a = (STArray s Int (Maybe a), Front s,Back s,QSize s,Int)
type Front s = STRef s Int
type Back s = STRef s Int
type QSize s = STRef s Int
type QAddr = Int
new :: Int -> ST s (AddrQueue s a)
enQueue :: AddrQueue s a -> a -> ST s QAddr
deQueue :: AddrQueue s a -> ST s (a,QAddr)
reQueue :: AddrQueue s a -> a -> ST s QAddr
getSize :: AddrQueue s a -> ST s Int
getMax :: AddrQueue s a -> ST s Int
deQueueWhile :: AddrQueue s a -> (a -> Bool) -> ST s [a]
enList :: AddrQueue s a -> [a] -> ST s [QAddr]
update :: AddrQueue s a -> QAddr -> (a -> a) -> ST s ()
clear :: AddrQueue s a -> ST s ()
space :: AddrQueue s a -> ST s Int
------------------------------------------------------------------------------
assertM True = return ()
assertM False = error "Assertion Failed"
insert x y z = setQueueVal x y (Just z)
new n
= do { q <- newSTArray (0,n) Nothing
; f <- newSTRef (-1)
; b <- newSTRef 0
; s <- newSTRef 0
; return (q,f,b,s,n)
}
clear (q,f,b,s,n)
= do { mapM (\x -> writeSTArray q x Nothing) [0 .. n]
; writeSTRef f (-1)
; writeSTRef b 0
; writeSTRef s 0
}
enQueue q elem
= do { sz <- getSize q
; max <- getMax q
; () <- assertM (sz < max)
; f <- getFront q
; let f' = (f+1) `mod` max
; setQueueVal q f' (Just elem)
; setSize q (sz+1)
; setFront q f'
; return f'
}
reQueue q elem
= do { sz <- getSize q
; max <- getMax q
; assertM (sz < max)
; b <- getBack q
; let b' = (b-1) `mod` max
; setQueueVal q b' (Just elem)
; setSize q (sz+1)
; setBack q b'
; return b'
}
deQueue q
= do { sz <- getSize q
; max <- getMax q
; assertM (sz > 0)
; b <- getBack q
; mj <- getQueueVal q b
; let j = mj `catchEx` error "deQueue"
; setSize q (sz-1)
; setBack q $ (b+1) `mod` max
; return (j,b)
}
space q
= do { sz <- getSize q
; m <- getMax q
; return $ m - sz
}
deQueueWhile q f
= do { sz <- getSize q
; if (sz < 1) then return []
else do { (elem,addr) <- deQueue q
; if (f elem) then do { elems <- deQueueWhile q f
; return (elem:elems)
}
else do { reQueue q elem
; return []
}
}
}
enList q [] = return []
enList q (x:xs)
= do { sz <- space q
; if (sz > 0) then do { a <- enQueue q x
; l <- enList q xs
; return $ a:l
}
else return []
}
assignAddrs q l
= do { let len = length l
; sz <- space q
; max <- getMax q
; assertM $ sz >= len
; f <- getFront q
; let f' = f+1
; let addrs = map (`mod` max) [f' .. f'+len]
; let bindings = zip l addrs
; return bindings
}
assignAddr q x
= do { ans <- assignAddrs q [x]
; return $ head ans
}
iterateQueue q f
= do { front <- getFront q
; back <- getBack q
; max <- getMax q
; updateWhile q front front back max f
}
where updateWhile q front n back max f
| n == back = return ()
| otherwise = do { val <- getQueueVal q n
; val <- case val of
Just x -> return $ Just $ f x
Nothing -> return Nothing
; setQueueVal q n val
; updateWhile q front ((n+1) `mod` max) back max f
}
update q n f
= do { x <- getQueueVal q n
; setQueueVal q n $ map f x
}
-------------------------------------------------------------------------
getSize (q,f,b,s,m) = readSTRef s
setSize (q,f,b,s,m) v = writeSTRef s v
getMax (q,f,b,s,m) = return m
getFront (q,f,b,s,m) = readSTRef f
setFront (q,f,b,s,m) v = writeSTRef f v
getBack (q,f,b,s,m) = readSTRef b
setBack (q,f,b,s,m) v = writeSTRef b v
setQueueVal (q,f,b,s,m) n elem = writeSTArray q n elem
getQueueVal (q,f,b,s,m) n = readSTArray q n
byron