Repository : ssh://darcs.haskell.org//srv/darcs/testsuite On branch : master
http://hackage.haskell.org/trac/ghc/changeset/b5bc2fdd7bb624c0562997965d4f6e1f21905750 >--------------------------------------------------------------- commit b5bc2fdd7bb624c0562997965d4f6e1f21905750 Author: Edward Z. Yang <[email protected]> Date: Mon Apr 4 14:59:45 2011 +0100 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 <[email protected]> >--------------------------------------------------------------- tests/ghc-regress/codeGen/should_run/all.T | 1 + tests/ghc-regress/codeGen/should_run/cgrun066.hs | 22 ++++++++++++++++++++ .../ghc-regress/codeGen/should_run/cgrun066.stdout | 1 + 3 files changed, 24 insertions(+), 0 deletions(-) diff --git a/tests/ghc-regress/codeGen/should_run/all.T b/tests/ghc-regress/codeGen/should_run/all.T index 48bb06c..e0322cb 100644 --- a/tests/ghc-regress/codeGen/should_run/all.T +++ b/tests/ghc-regress/codeGen/should_run/all.T @@ -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, ['']) diff --git a/tests/ghc-regress/codeGen/should_run/cgrun066.hs b/tests/ghc-regress/codeGen/should_run/cgrun066.hs new file mode 100644 index 0000000..aa1c621 --- /dev/null +++ b/tests/ghc-regress/codeGen/should_run/cgrun066.hs @@ -0,0 +1,22 @@ +{-# 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) diff --git a/tests/ghc-regress/codeGen/should_run/cgrun066.stdout b/tests/ghc-regress/codeGen/should_run/cgrun066.stdout new file mode 100644 index 0000000..b9cb48f --- /dev/null +++ b/tests/ghc-regress/codeGen/should_run/cgrun066.stdout @@ -0,0 +1 @@ +885 _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
