Simon Jakobi pushed to branch wip/sjakobi/T16122 at Glasgow Haskell Compiler / GHC
Commits:
-
0159e431
by Simon Jakobi at 2026-03-08T15:25:37+01:00
3 changed files:
- + testsuite/tests/simplCore/should_compile/T16122.hs
- + testsuite/tests/simplCore/should_compile/T16122.stderr
- testsuite/tests/simplCore/should_compile/all.T
Changes:
| 1 | +{-# LANGUAGE TypeApplications #-}
|
|
| 2 | +-- Test that the Core for f isn't "worse" than g's.
|
|
| 3 | +-- The optimized Core for f used to involve dictionary-passing. See #16122.
|
|
| 4 | +module T16122 (f, g) where
|
|
| 5 | + |
|
| 6 | +import Data.Int (Int64)
|
|
| 7 | + |
|
| 8 | +f :: Double -> Int64
|
|
| 9 | +f = round
|
|
| 10 | + |
|
| 11 | +g :: Double -> Int64
|
|
| 12 | +g = fromIntegral @Int @Int64 . round |
| 1 | +f = \ x ->
|
|
| 2 | + I64#
|
|
| 3 | + (case x of { D# ds1 ->
|
|
| 4 | + case {__ffi_static_ccall_unsafe ghc-internal:rintDouble :: Double#
|
|
| 5 | + -> State# RealWorld
|
|
| 6 | + -> (# State# RealWorld, Double# #)}
|
|
| 7 | + ds1 realWorld#
|
|
| 8 | + of
|
|
| 9 | + { (# _, ds3 #) ->
|
|
| 10 | + intToInt64# (double2Int# ds3)
|
|
| 11 | + }
|
|
| 12 | + })
|
|
| 13 | + |
|
| 14 | +g = \ x ->
|
|
| 15 | + I64#
|
|
| 16 | + (case x of { D# ds1 ->
|
|
| 17 | + case {__ffi_static_ccall_unsafe ghc-internal:rintDouble :: Double#
|
|
| 18 | + -> State# RealWorld
|
|
| 19 | + -> (# State# RealWorld, Double# #)}
|
|
| 20 | + ds1 realWorld#
|
|
| 21 | + of
|
|
| 22 | + { (# _, ds3 #) ->
|
|
| 23 | + intToInt64# (double2Int# ds3)
|
|
| 24 | + }
|
|
| 25 | + })
|
|
| 26 | + |
| ... | ... | @@ -295,6 +295,10 @@ test('T15631', |
| 295 | 295 | normal,
|
| 296 | 296 | makefile_test, ['T15631'])
|
| 297 | 297 | test('T15673', normal, compile, ['-O'])
|
| 298 | +test('T16122', [when(wordsize(32), skip)],
|
|
| 299 | + multimod_compile_filter,
|
|
| 300 | + ['T16122', '-O -ddump-simpl -dsuppress-all -dsuppress-uniques -dno-typeable-binds',
|
|
| 301 | + "sed -n '/^f = /,/^$/p;/^g = /,/^$/p'"])
|
|
| 298 | 302 | test('T16288', normal, multimod_compile, ['T16288B', '-O -dcore-lint -v0'])
|
| 299 | 303 | test('T16348', normal, compile, ['-O'])
|
| 300 | 304 | test('T16918', normal, compile, ['-O'])
|