diff --git a/tests/ghc-regress/codeGen/should_run/Cgrun067.hs b/tests/ghc-regress/codeGen/should_run/Cgrun067.hs
new file mode 100644
index 0000000000000000000000000000000000000000..f8de762a62de9e024bf78ad51ed6b47ab9415c78
--- /dev/null
+++ b/tests/ghc-regress/codeGen/should_run/Cgrun067.hs
@@ -0,0 +1,16 @@
+-- Bug doesn't show up on -O0
+{-# OPTIONS_GHC -O #-}
+module Cgrun067 (miscompiledFn) where
+
+import Foreign.C
+import Foreign
+
+miscompiledFn :: CString -> IO String
+miscompiledFn cp = do
+  l <- lengthArray0 0 cp
+  if l <= 0 then return "" else loop "" (l-1)
+  where
+    loop s i = do
+        xval <- peekElemOff cp i
+        let val = castCCharToChar xval
+        val `seq` if i <= 0 then return (val:s) else loop (val:s) (i-1)
diff --git a/tests/ghc-regress/codeGen/should_run/all.T b/tests/ghc-regress/codeGen/should_run/all.T
index e0322cbb482a8c8cdc524530dca2aa9ec46b9176..a5e977be54d8d0e88c62e2d745f6ea0a68fd1ad2 100644
--- a/tests/ghc-regress/codeGen/should_run/all.T
+++ b/tests/ghc-regress/codeGen/should_run/all.T
@@ -73,6 +73,7 @@ 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('cgrun067', normal, compile_and_run, [''])
 
 test('1861', extra_run_opts('0'), compile_and_run, [''])
 
diff --git a/tests/ghc-regress/codeGen/should_run/cgrun067.hs b/tests/ghc-regress/codeGen/should_run/cgrun067.hs
new file mode 100644
index 0000000000000000000000000000000000000000..9fcbbd71d2147b40e15836ef01cce22776f034d0
--- /dev/null
+++ b/tests/ghc-regress/codeGen/should_run/cgrun067.hs
@@ -0,0 +1,11 @@
+-- This test-case tickled a bug where an optimization pass incorrectly
+-- reloaded a stack slot before the slot was initialized.  It was a bit
+-- tricky to reproduce, and I don't really know why this particular
+-- harness was necessary.
+
+-- Miscompiled code must be in another module, otherwise problem doesn't
+-- show up.
+import Cgrun067 (miscompiledFn)
+import Foreign.C.String
+
+main = withCString "foobar" $ \p -> print =<< miscompiledFn p
diff --git a/tests/ghc-regress/codeGen/should_run/cgrun067.stdout b/tests/ghc-regress/codeGen/should_run/cgrun067.stdout
new file mode 100644
index 0000000000000000000000000000000000000000..14e24d419005f523527a442d83ba15a7ce15bab1
--- /dev/null
+++ b/tests/ghc-regress/codeGen/should_run/cgrun067.stdout
@@ -0,0 +1 @@
+"foobar"