Test Trac #4957
authorsimonpj <simonpj@microsoft.com>
Tue, 15 Feb 2011 14:46:34 +0000 (14:46 +0000)
committersimonpj <simonpj@microsoft.com>
Tue, 15 Feb 2011 14:46:34 +0000 (14:46 +0000)
testsuite/tests/ghc-regress/simplCore/should_compile/Makefile
testsuite/tests/ghc-regress/simplCore/should_compile/T4957.hs [new file with mode: 0644]
testsuite/tests/ghc-regress/simplCore/should_compile/all.T

index bf7bfcb..6061507 100644 (file)
@@ -42,3 +42,7 @@ EvalTest:
 # when there are (as expected) no matches
 T4945:
        -('$(TEST_HC)' -c -O2 -fno-liberate-case T4945.hs -ddump-simpl -dsuppress-uniques | grep 'STUArray')
+
+# When this one works there are no 'lets' at all
+T4957:
+       -('$(TEST_HC)' -c -O T4957.hs -ddump-simpl -dsuppress-uniques | grep 'let')
diff --git a/testsuite/tests/ghc-regress/simplCore/should_compile/T4957.hs b/testsuite/tests/ghc-regress/simplCore/should_compile/T4957.hs
new file mode 100644 (file)
index 0000000..63086cd
--- /dev/null
@@ -0,0 +1,19 @@
+{-# LANGUAGE MagicHash #-}
+module T4957 where
+
+import GHC.Base
+
+f :: Bool -> Int -> Int
+f b 0 = 0
+f b x = let y = case b of
+                 True -> case f b (x-1) of
+                            I# v -> I# (v -# 1#)
+                 False -> case f b (x-1) of
+                            I# v -> I# (v +# 1#)
+      in
+      case b of
+         True -> case y of
+                   I# w -> I# (w -# 1#)
+
+         False -> case y of
+                   I# w -> I# (w +# 1#)
index 4652972..0b927c6 100644 (file)
@@ -111,3 +111,8 @@ test('T4945',
      normal,
      run_command,
      ['$MAKE -s --no-print-directory T4945'])
+
+test('T4957',
+     normal,
+     run_command,
+     ['$MAKE -s --no-print-directory T4957'])