summaryrefslogtreecommitdiff
path: root/testsuite/tests/simplCore
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2018-09-26 04:29:19 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2018-09-26 04:41:56 +0100
commitd25fa45e377253cfbe26e410075dda9d58bb869c (patch)
tree4ff57158c78b82c10b212bc319f660060106c530 /testsuite/tests/simplCore
parent4bdb10ca7ba14f00dd62270eadab4f93238227bc (diff)
downloadhaskell-d25fa45e377253cfbe26e410075dda9d58bb869c.tar.gz
Fix constant-folding for Integer shifts
In this patch commit 869f69fd4a78371c221e6d9abd69a71440a4679a Author: Simon Peyton Jones <simonpj@microsoft.com> Date: Wed Dec 11 18:19:34 2013 +0000 Guarding against silly shifts we deal with silly shifts like (Sll 1 9223372036854775807). But I only dealt with primops that Int# and Word#. Alas, the same problem affects shifts of Integer, as Trac #15673 showed. Fortunately, the problem is easy to fix.
Diffstat (limited to 'testsuite/tests/simplCore')
-rw-r--r--testsuite/tests/simplCore/should_compile/T15673.hs6
-rw-r--r--testsuite/tests/simplCore/should_compile/all.T1
2 files changed, 7 insertions, 0 deletions
diff --git a/testsuite/tests/simplCore/should_compile/T15673.hs b/testsuite/tests/simplCore/should_compile/T15673.hs
new file mode 100644
index 0000000000..30baa37d3d
--- /dev/null
+++ b/testsuite/tests/simplCore/should_compile/T15673.hs
@@ -0,0 +1,6 @@
+module T14573 where
+
+import Data.Bits (shift)
+
+badOne :: [Int] -> Integer -- replace Integer by Int and all is good!
+badOne is = sum $ zipWith (\n _->shift 1 n) [0..] is
diff --git a/testsuite/tests/simplCore/should_compile/all.T b/testsuite/tests/simplCore/should_compile/all.T
index d572d04e15..391994e3df 100644
--- a/testsuite/tests/simplCore/should_compile/all.T
+++ b/testsuite/tests/simplCore/should_compile/all.T
@@ -326,3 +326,4 @@ test('T15631',
normal,
run_command,
['$MAKE -s --no-print-directory T15631'])
+test('T15673', normal, compile, ['-O'])