summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Jakobi <simon.jakobi@gmail.com>2021-04-03 01:00:20 +0200
committerSimon Jakobi <simon.jakobi@gmail.com>2021-04-03 01:04:30 +0200
commit2975ea4706137031aa9fcc479bb8d55311d664d1 (patch)
tree52e401b258d328ddd35b6c9d9f7cf2ac9d66a038
parentce706faeef3964116c6e1dd0e6ae2f2e77fde57d (diff)
downloadhaskell-wip/sjakobi/T7378-test.tar.gz
Add regression test for #7378wip/sjakobi/T7378-test
Closes #7378.
-rw-r--r--testsuite/tests/simplCore/should_compile/T7378.hs11
-rw-r--r--testsuite/tests/simplCore/should_compile/T7378.stderr3
-rw-r--r--testsuite/tests/simplCore/should_compile/all.T1
3 files changed, 15 insertions, 0 deletions
diff --git a/testsuite/tests/simplCore/should_compile/T7378.hs b/testsuite/tests/simplCore/should_compile/T7378.hs
new file mode 100644
index 0000000000..d32014bb5a
--- /dev/null
+++ b/testsuite/tests/simplCore/should_compile/T7378.hs
@@ -0,0 +1,11 @@
+module T7378 where
+
+-- The original example, now compiled to a simple right-shift
+fun0 :: Int -> Int
+fun0 i = i `div` 2
+
+-- We expect CSE to combine the alternatives of a redundant
+-- case analysis on `i > 0`.
+-- This didn't happen before GHC 8.2.
+fun1 :: Int -> Int
+fun1 i = i `div` 12345
diff --git a/testsuite/tests/simplCore/should_compile/T7378.stderr b/testsuite/tests/simplCore/should_compile/T7378.stderr
new file mode 100644
index 0000000000..b8bee5ec94
--- /dev/null
+++ b/testsuite/tests/simplCore/should_compile/T7378.stderr
@@ -0,0 +1,3 @@
+ case i of { I# ww1 ->
+ case <# ww1 0# of {
+ = / i -> case i of { I# ww1 -> I# (uncheckedIShiftRA# ww1 1#) }
diff --git a/testsuite/tests/simplCore/should_compile/all.T b/testsuite/tests/simplCore/should_compile/all.T
index 3a16d55508..70324ea44d 100644
--- a/testsuite/tests/simplCore/should_compile/all.T
+++ b/testsuite/tests/simplCore/should_compile/all.T
@@ -130,6 +130,7 @@ test('T6082-RULE', normal, compile, [''])
test('T7165', [], makefile_test, ['T7165'])
test('T7287', normal, compile, [''])
test('T7360', only_ways(['optasm']), compile, ['-ddump-simpl -dsuppress-uniques -dsuppress-ticks'])
+test('T7378', [grep_errmsg(r'case'), only_ways(['optasm'])], compile, ['-O -funfolding-use-threshold=109 -ddump-simpl -dsuppress-all -dsuppress-uniques'])
test('T5366',
normal,
makefile_test, ['T5366'])