summaryrefslogtreecommitdiff
path: root/testsuite/tests/numeric
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-09-15 17:59:23 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-09-23 16:01:00 -0400
commit33eb4a4e396e76cf8122a97734d0e8cdd850c747 (patch)
tree873251a30944cb99ee9cbd638632ce5c8d59e146 /testsuite/tests/numeric
parentac378d3efda35546fca8f2ffc08433187e93063b (diff)
downloadhaskell-33eb4a4e396e76cf8122a97734d0e8cdd850c747.tar.gz
Constant-folding for timesInt2# (#20374)
Diffstat (limited to 'testsuite/tests/numeric')
-rw-r--r--testsuite/tests/numeric/should_compile/T20374.hs31
-rw-r--r--testsuite/tests/numeric/should_compile/T20374.stderr29
-rw-r--r--testsuite/tests/numeric/should_compile/all.T1
3 files changed, 61 insertions, 0 deletions
diff --git a/testsuite/tests/numeric/should_compile/T20374.hs b/testsuite/tests/numeric/should_compile/T20374.hs
new file mode 100644
index 0000000000..900d4b8ac5
--- /dev/null
+++ b/testsuite/tests/numeric/should_compile/T20374.hs
@@ -0,0 +1,31 @@
+{-# LANGUAGE MagicHash #-}
+{-# LANGUAGE UnboxedTuples #-}
+{-# LANGUAGE NegativeLiterals #-}
+
+module T20374 where
+
+import GHC.Exts
+
+foo0 (# #) = timesInt2# 100005# 6832#
+foo1 (# #) = timesInt2# -100005# 6832#
+foo2 (# #) = timesInt2# -100005# -6832#
+foo3 (# #) = timesInt2# 100005# -6832#
+
+foo4 (# #) = timesInt2# 100005# 0#
+foo5 (# #) = timesInt2# 0# 6832#
+
+foo6 other = case timesInt2# 1# other of
+ (# 0#, _ , l #) -> l
+ _ -> error "Unexpected foo6 result"
+foo7 other = case timesInt2# other 1# of
+ (# 0#, _ , l #) -> l
+ _ -> error "Unexpected foo7 result"
+
+foo8 (# #) = timesInt2# 1# 128#
+
+foo9 (# #) = timesInt2# 1# -128#
+
+foo10 (# #) = let (I# m) = maxBound
+ in case timesInt2# m m of
+ (# 1#, _ , 1# #) -> 1#
+ _ -> error "Unexpected foo10 result"
diff --git a/testsuite/tests/numeric/should_compile/T20374.stderr b/testsuite/tests/numeric/should_compile/T20374.stderr
new file mode 100644
index 0000000000..86e3ee2180
--- /dev/null
+++ b/testsuite/tests/numeric/should_compile/T20374.stderr
@@ -0,0 +1,29 @@
+
+==================== Tidy Core ====================
+Result size of Tidy Core
+ = {terms: 44, types: 107, coercions: 0, joins: 0/0}
+
+foo0 = \ _ -> (# 0#, 0#, 683234160# #)
+
+foo1 = \ _ -> (# 0#, -1#, -683234160# #)
+
+foo2 = foo0
+
+foo3 = foo1
+
+foo4 = \ _ -> (# 0#, 0#, 0# #)
+
+foo5 = foo4
+
+foo6 = \ other -> other
+
+foo7 = foo6
+
+foo8 = \ _ -> (# 0#, 0#, 128# #)
+
+foo9 = \ _ -> (# 0#, -1#, -128# #)
+
+foo10 = \ _ -> 1#
+
+
+
diff --git a/testsuite/tests/numeric/should_compile/all.T b/testsuite/tests/numeric/should_compile/all.T
index 5a0f9efae3..db6867efeb 100644
--- a/testsuite/tests/numeric/should_compile/all.T
+++ b/testsuite/tests/numeric/should_compile/all.T
@@ -13,3 +13,4 @@ test('T19892', normal, compile, ['-O -ddump-rule-firings'])
test('T20062', [ grep_errmsg(r'integer') ], compile, ['-ddump-simpl -O -dsuppress-all'])
test('T20245', normal, compile, ['-ddump-simpl -O -dsuppress-all -dno-typeable-binds'])
test('T20376', normal, compile, ['-ddump-simpl -O -dsuppress-all -dsuppress-uniques -dno-typeable-binds'])
+test('T20374', normal, compile, ['-ddump-simpl -O -dsuppress-all -dno-typeable-binds -dsuppress-uniques'])