summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-06-10 09:25:57 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-06-14 10:48:51 -0400
commit5279dda861f6a5cc804be88dc5f0ff2442660149 (patch)
tree1ef81e731c456a2d30ee36430077d96399ebc369 /testsuite/tests
parenteffdd948056923f3bc03688c24d7e0339d6272f5 (diff)
downloadhaskell-5279dda861f6a5cc804be88dc5f0ff2442660149.tar.gz
PrelRules: Don't break let/app invariant in shiftRule
Previously shiftRule would rewrite as invalid shift like ``` let x = I# (uncheckedIShiftL# n 80) in ... ``` to ``` let x = I# (error "invalid shift") in ... ``` However, this breaks the let/app invariant as `error` is not okay-for-speculation. There isn't an easy way to avoid this so let's not try. Instead we just take advantage of the undefined nature of invalid shifts and return zero. Fixes #16742.
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/codeGen/should_run/T16449_2.hs4
-rw-r--r--testsuite/tests/codeGen/should_run/T16449_2.stderr1
-rw-r--r--testsuite/tests/codeGen/should_run/T16449_2.stdout2
-rw-r--r--testsuite/tests/codeGen/should_run/all.T2
4 files changed, 7 insertions, 2 deletions
diff --git a/testsuite/tests/codeGen/should_run/T16449_2.hs b/testsuite/tests/codeGen/should_run/T16449_2.hs
index 3424d43e25..acb885369c 100644
--- a/testsuite/tests/codeGen/should_run/T16449_2.hs
+++ b/testsuite/tests/codeGen/should_run/T16449_2.hs
@@ -5,5 +5,9 @@ module Main where
import GHC.Prim
import GHC.Int
+-- Test that large unchecked shifts, which constitute undefined behavior, do
+-- not crash the compiler and instead evaluate to 0.
+-- See Note [Guarding against silly shifts] in PrelRules.
+
-- Shift should be larger than the word size (e.g. 64 on 64-bit) for this test.
main = print (I# (uncheckedIShiftL# 1# 1000#))
diff --git a/testsuite/tests/codeGen/should_run/T16449_2.stderr b/testsuite/tests/codeGen/should_run/T16449_2.stderr
deleted file mode 100644
index 869a5b0f91..0000000000
--- a/testsuite/tests/codeGen/should_run/T16449_2.stderr
+++ /dev/null
@@ -1 +0,0 @@
-T16449_2: Bad shift length 1000
diff --git a/testsuite/tests/codeGen/should_run/T16449_2.stdout b/testsuite/tests/codeGen/should_run/T16449_2.stdout
new file mode 100644
index 0000000000..77ac542d4f
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T16449_2.stdout
@@ -0,0 +1,2 @@
+0
+
diff --git a/testsuite/tests/codeGen/should_run/all.T b/testsuite/tests/codeGen/should_run/all.T
index 5545c9ebb0..535ca8651e 100644
--- a/testsuite/tests/codeGen/should_run/all.T
+++ b/testsuite/tests/codeGen/should_run/all.T
@@ -196,4 +196,4 @@ test('T15892',
extra_run_opts('+RTS -G1 -A32k -RTS') ],
compile_and_run, ['-O'])
test('T16617', normal, compile_and_run, [''])
-test('T16449_2', [expect_broken_for(16742, ['dyn', 'ghci', 'optasm', 'threaded2']), exit_code(1)], compile_and_run, [''])
+test('T16449_2', exit_code(0), compile_and_run, [''])