Commit d7f30389 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Test case for CmmOpt inliner on non-single assignment code from new codegen.



The following test creates a nice, inner loop inside a procedure with
the new code generator, which tickles the invariant in CmmOpt that
all temporaries are single assignment and also a register allocator bug.
Signed-off-by: Edward Z. Yang's avatarEdward Z. Yang <ezyang@mit.edu>
parent d3642003
......@@ -72,6 +72,7 @@ test('cgrun061', normal, compile_and_run, [''])
test('cgrun062', normal, compile_and_run, [''])
test('cgrun063', normal, compile_and_run, [''])
test('cgrun065', normal, compile_and_run, [''])
test('cgrun066', normal, compile_and_run, [''])
test('1861', extra_run_opts('0'), compile_and_run, [''])
......
{-# LANGUAGE MagicHash, BangPatterns #-}
{-# OPTIONS_GHC -O0 #-}
import Foreign.C
import Data.Word
import Foreign.Ptr
import GHC.Exts
import Control.Exception
hashStr :: Ptr Word8 -> Int -> Int
hashStr (Ptr a#) (I# len#) = loop 0# 0#
where
loop h n | n GHC.Exts.==# len# = I# h
| otherwise = loop h2 (n GHC.Exts.+# 1#)
where !c = ord# (indexCharOffAddr# a# n)
!h2 = (c GHC.Exts.+# (h GHC.Exts.*# 128#)) `remInt#` 4091#
-- Infinite loops with new code generator + C-- optimizations
main = do
withCStringLen "ff" $ \(ptr, l) -> do
print (hashStr (castPtr ptr) l)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment