diff options
author | Edward Z. Yang <ezyang@mit.edu> | 2011-06-28 08:20:50 -0400 |
---|---|---|
committer | Edward Z. Yang <ezyang@mit.edu> | 2011-06-28 08:20:50 -0400 |
commit | ed6f0d62ef483ec01d443a630e3cf806a7a094df (patch) | |
tree | 9c909f096a631cf83afbe2731517d5bdc7663f96 | |
parent | 3d99ee1507fedf9e583a4397e41e3310bcc70b6c (diff) | |
download | haskell-ed6f0d62ef483ec01d443a630e3cf806a7a094df.tar.gz |
Another variant of hashStr, this one caught a Hoopl bug.
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
-rw-r--r-- | testsuite/tests/ghc-regress/codeGen/should_compile/all.T | 1 | ||||
-rw-r--r-- | testsuite/tests/ghc-regress/codeGen/should_compile/cg008.hs | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/testsuite/tests/ghc-regress/codeGen/should_compile/all.T b/testsuite/tests/ghc-regress/codeGen/should_compile/all.T index 2f61d79399..ba29c2a145 100644 --- a/testsuite/tests/ghc-regress/codeGen/should_compile/all.T +++ b/testsuite/tests/ghc-regress/codeGen/should_compile/all.T @@ -5,6 +5,7 @@ test('cg004', normal, compile, ['']) test('cg005', only_ways(['optasm']), compile, ['']) test('cg006', normal, compile, ['']) test('cg007', normal, compile, ['']) +test('cg008', normal, compile, ['']) test('1916', normal, compile, ['']) test('2388', normal, compile, ['']) diff --git a/testsuite/tests/ghc-regress/codeGen/should_compile/cg008.hs b/testsuite/tests/ghc-regress/codeGen/should_compile/cg008.hs new file mode 100644 index 0000000000..10099c1b48 --- /dev/null +++ b/testsuite/tests/ghc-regress/codeGen/should_compile/cg008.hs @@ -0,0 +1,21 @@ +{-# LANGUAGE MagicHash, BangPatterns #-} +{-# OPTIONS_GHC -O0 #-} + +-- Variant of cgrun066; compilation as a module is different. + +module Cg008 (hashStr) where + +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# |