summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorAlan Mock <alan@alanmock.com>2016-06-03 22:16:27 +0200
committerBen Gamari <ben@smart-cactus.org>2016-06-04 09:35:49 +0200
commit02f893eb4fe3f75f0a9dc7e723568f4c75de5785 (patch)
tree37c8b38df14d99e8b9a625d3c1c2a95974bc0a33 /testsuite
parent079c1b8caed22db2be24f3304c56db56292670e1 (diff)
downloadhaskell-02f893eb4fe3f75f0a9dc7e723568f4c75de5785.tar.gz
integer-gmp: Make minusInteger more efficient
Give `minusInteger` its own implementation. Previously `minusInteger` used `plusInteger` and `negateInteger`, which meant it always allocated. Now it works more like `plusInteger`. Reviewers: goldfire, hvr, bgamari, austin Reviewed By: hvr, bgamari, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2278 GHC Trac Issues: #12129
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/lib/integer/all.T2
-rw-r--r--testsuite/tests/lib/integer/plusMinusInteger.hs36
-rw-r--r--testsuite/tests/lib/integer/plusMinusInteger.stdout1
-rw-r--r--testsuite/tests/perf/should_run/all.T3
4 files changed, 40 insertions, 2 deletions
diff --git a/testsuite/tests/lib/integer/all.T b/testsuite/tests/lib/integer/all.T
index c0b39b01e4..327f5778f4 100644
--- a/testsuite/tests/lib/integer/all.T
+++ b/testsuite/tests/lib/integer/all.T
@@ -2,6 +2,7 @@ test('integerBits', normal, compile_and_run, [''])
test('integerConversions', normal, compile_and_run, [''])
# skip ghci as it doesn't support unboxed tuples
test('integerGmpInternals', [reqlib('integer-gmp'), omit_ways('ghci')], compile_and_run, [''])
+test('plusMinusInteger', [reqlib('integer-gmp'), omit_ways('ghci')], compile_and_run, [''])
test('integerConstantFolding',
[extra_clean(['integerConstantFolding.simpl']),
when(compiler_debugged(), expect_broken(11006))],
@@ -16,4 +17,3 @@ test('IntegerConversionRules',
run_command,
['$MAKE -s --no-print-directory IntegerConversionRules'])
test('gcdInteger', normal, compile_and_run, [''])
-
diff --git a/testsuite/tests/lib/integer/plusMinusInteger.hs b/testsuite/tests/lib/integer/plusMinusInteger.hs
new file mode 100644
index 0000000000..ec8d7e6ab4
--- /dev/null
+++ b/testsuite/tests/lib/integer/plusMinusInteger.hs
@@ -0,0 +1,36 @@
+module Main (main) where
+
+
+main :: IO ()
+main = do
+ print $ length vals
+
+ where
+ boundaries :: [Integer]
+ boundaries = [fromIntegral (maxBound :: Int) - 3,
+ fromIntegral (maxBound :: Int) - 2,
+ fromIntegral (maxBound :: Int) - 1,
+ fromIntegral (maxBound :: Int),
+ fromIntegral (maxBound :: Int) + 1,
+ fromIntegral (maxBound :: Int) + 2,
+ fromIntegral (maxBound :: Int) + 3,
+
+ fromIntegral (minBound :: Int) - 3,
+ fromIntegral (minBound :: Int) - 2,
+ fromIntegral (minBound :: Int) - 1,
+ fromIntegral (minBound :: Int),
+ fromIntegral (minBound :: Int) + 1,
+ fromIntegral (minBound :: Int) + 2,
+ fromIntegral (minBound :: Int) + 3,
+
+ fromIntegral (maxBound :: Word) - 3,
+ fromIntegral (maxBound :: Word) - 2,
+ fromIntegral (maxBound :: Word) - 1,
+ fromIntegral (maxBound :: Word),
+ fromIntegral (maxBound :: Word) + 1,
+ fromIntegral (maxBound :: Word) + 2,
+ fromIntegral (maxBound :: Word) + 3,
+
+ -3, -2, -1, 0, 1, 2, 3]
+ vals = filter (\(x, y) -> x /= y) [(x - y, x + negate y) |
+ x <- boundaries, y <- boundaries]
diff --git a/testsuite/tests/lib/integer/plusMinusInteger.stdout b/testsuite/tests/lib/integer/plusMinusInteger.stdout
new file mode 100644
index 0000000000..c227083464
--- /dev/null
+++ b/testsuite/tests/lib/integer/plusMinusInteger.stdout
@@ -0,0 +1 @@
+0 \ No newline at end of file
diff --git a/testsuite/tests/perf/should_run/all.T b/testsuite/tests/perf/should_run/all.T
index 81a55350e1..d039f68dbf 100644
--- a/testsuite/tests/perf/should_run/all.T
+++ b/testsuite/tests/perf/should_run/all.T
@@ -204,9 +204,10 @@ test('T5549',
# expected value: 3362958676 (Windows)
# 2014-12-01: 4096606332 (Windows) integer-gmp2
- (wordsize(64), 8193140752, 5)]),
+ (wordsize(64), 5793140200, 5)]),
# expected value: 6725846120 (amd64/Linux)
# 8193140752 (amd64/Linux) integer-gmp2
+ # 5793140200 (amd64/Linux) integer-gmp2
only_ways(['normal'])
],
compile_and_run,