diff options
author | Reid Barton <rwbarton@gmail.com> | 2015-06-25 13:53:57 -0400 |
---|---|---|
committer | Reid Barton <rwbarton@gmail.com> | 2015-06-25 13:53:58 -0400 |
commit | a2f828a370b220839ad9b31a274c0198ef91b7fe (patch) | |
tree | d4f238143f0dd7c891f90e9b2bd10b41c6470e19 /testsuite/tests/codeGen | |
parent | c7b6fb59eca478650dcb391a6f424e3c42a155dc (diff) | |
download | haskell-a2f828a370b220839ad9b31a274c0198ef91b7fe.tar.gz |
Be aware of overlapping global STG registers in CmmSink (#10521)
Summary:
On x86_64, commit e2f6bbd3a27685bc667655fdb093734cb565b4cf assigned
the STG registers F1 and D1 the same hardware register (xmm1), and
the same for the registers F2 and D2, etc. When mixing calls to
functions involving Float#s and Double#s, this can cause wrong Cmm
optimizations that assume the F1 and D1 registers are independent.
Reviewers: simonpj, austin
Reviewed By: austin
Subscribers: simonpj, thomie, bgamari
Differential Revision: https://phabricator.haskell.org/D993
GHC Trac Issues: #10521
Diffstat (limited to 'testsuite/tests/codeGen')
-rw-r--r-- | testsuite/tests/codeGen/should_run/T10521.hs | 11 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_run/T10521.stdout | 1 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_run/T10521b.hs | 18 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_run/T10521b.stdout | 1 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_run/all.T | 2 |
5 files changed, 33 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/T10521.hs b/testsuite/tests/codeGen/should_run/T10521.hs new file mode 100644 index 0000000000..e770ba315c --- /dev/null +++ b/testsuite/tests/codeGen/should_run/T10521.hs @@ -0,0 +1,11 @@ +import Data.Word( Word8 ) + +toV :: Float -> Word8 +toV d = let coeff = significand d * 255.9999 / d + a = truncate $ d * coeff + b = exponent d + in a `seq` (b `seq` a) + +main :: IO () +main = + print $ map toV [ 3.56158e-2, 0.7415215, 0.5383201, 0.1289829, 0.45520145 ] diff --git a/testsuite/tests/codeGen/should_run/T10521.stdout b/testsuite/tests/codeGen/should_run/T10521.stdout new file mode 100644 index 0000000000..9843a1725d --- /dev/null +++ b/testsuite/tests/codeGen/should_run/T10521.stdout @@ -0,0 +1 @@ +[145,189,137,132,233] diff --git a/testsuite/tests/codeGen/should_run/T10521b.hs b/testsuite/tests/codeGen/should_run/T10521b.hs new file mode 100644 index 0000000000..d0433f9b76 --- /dev/null +++ b/testsuite/tests/codeGen/should_run/T10521b.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE MagicHash #-} + +import GHC.Exts + +f :: Float# -> Float# +f x = x +{-# NOINLINE f #-} + +g :: Double# -> Double# +g x = x +{-# NOINLINE g #-} + +h :: Float -> Float +h (F# x) = let a = F# (f x) + b = D# (g (2.0##)) + in a `seq` (b `seq` a) + +main = print (h 1.0) diff --git a/testsuite/tests/codeGen/should_run/T10521b.stdout b/testsuite/tests/codeGen/should_run/T10521b.stdout new file mode 100644 index 0000000000..d3827e75a5 --- /dev/null +++ b/testsuite/tests/codeGen/should_run/T10521b.stdout @@ -0,0 +1 @@ +1.0 diff --git a/testsuite/tests/codeGen/should_run/all.T b/testsuite/tests/codeGen/should_run/all.T index 9125f0bd2d..db2d04ed95 100644 --- a/testsuite/tests/codeGen/should_run/all.T +++ b/testsuite/tests/codeGen/should_run/all.T @@ -133,3 +133,5 @@ test('cgrun074', normal, compile_and_run, ['']) test('CmmSwitchTest', when(fast(), skip), compile_and_run, ['']) test('T10245', expect_broken(10246), compile_and_run, ['']) test('T10246', expect_broken(10246), compile_and_run, ['']) +test('T10521', normal, compile_and_run, ['']) +test('T10521b', normal, compile_and_run, ['']) |