summaryrefslogtreecommitdiff
path: root/testsuite/tests/numeric
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-09-16 12:34:41 +0200
committerSylvain Henry <sylvain@haskus.fr>2021-10-04 08:28:23 +0000
commitb3267fadd42429e6253cefd85d556aeea4dadd6f (patch)
tree8c2aa57cb003fc753e2a23d75ea8764092c5fc33 /testsuite/tests/numeric
parente8693713a40072a0dec5e83b1a31ffb0ee881633 (diff)
downloadhaskell-b3267fadd42429e6253cefd85d556aeea4dadd6f.tar.gz
Constant folding for negate (#20347)
Only for small integral types for now.
Diffstat (limited to 'testsuite/tests/numeric')
-rw-r--r--testsuite/tests/numeric/should_compile/T20347.hs12
-rw-r--r--testsuite/tests/numeric/should_compile/T20347.stderr17
-rw-r--r--testsuite/tests/numeric/should_compile/all.T1
3 files changed, 30 insertions, 0 deletions
diff --git a/testsuite/tests/numeric/should_compile/T20347.hs b/testsuite/tests/numeric/should_compile/T20347.hs
new file mode 100644
index 0000000000..2160004b49
--- /dev/null
+++ b/testsuite/tests/numeric/should_compile/T20347.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE MagicHash #-}
+{-# LANGUAGE UnboxedTuples #-}
+
+module T20347 where
+
+import GHC.Exts
+
+foo0 x = 10# +# (negateInt# x)
+foo1 x = (10# +# x) +# (negateInt# x)
+foo2 x = 10# -# (negateInt# x)
+foo3 x y = (negateInt# x) *# (negateInt# y)
+foo4 x = 10# *# (negateInt# x)
diff --git a/testsuite/tests/numeric/should_compile/T20347.stderr b/testsuite/tests/numeric/should_compile/T20347.stderr
new file mode 100644
index 0000000000..e4e80ada00
--- /dev/null
+++ b/testsuite/tests/numeric/should_compile/T20347.stderr
@@ -0,0 +1,17 @@
+
+==================== Tidy Core ====================
+Result size of Tidy Core
+ = {terms: 20, types: 15, coercions: 0, joins: 0/0}
+
+foo0 = \ x -> -# 10# x
+
+foo1 = \ _ -> 10#
+
+foo2 = \ x -> +# 10# x
+
+foo3 = *#
+
+foo4 = \ x -> *# -10# x
+
+
+
diff --git a/testsuite/tests/numeric/should_compile/all.T b/testsuite/tests/numeric/should_compile/all.T
index 5e8259a8fd..59b66f8d5f 100644
--- a/testsuite/tests/numeric/should_compile/all.T
+++ b/testsuite/tests/numeric/should_compile/all.T
@@ -15,3 +15,4 @@ test('T20245', normal, compile, ['-ddump-simpl -O -dsuppress-all -dno-typeable-b
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'])
test('T19769', normal, compile, ['-ddump-simpl -O -dsuppress-all -dno-typeable-binds -dsuppress-uniques'])
+test('T20347', normal, compile, ['-ddump-simpl -O -dsuppress-all -dno-typeable-binds -dsuppress-uniques'])