[GHC] #14742: Unboxed sums can treat Word#s as Int#s

GHC ghc-devs at haskell.org
Wed Jan 31 20:48:48 UTC 2018


#14742: Unboxed sums can treat Word#s as Int#s
-------------------------------------+-------------------------------------
        Reporter:  duog              |                Owner:  osa1
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.2.2
      Resolution:                    |             Keywords:  UnboxedSums
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by duog):

 Why does `RuntimeRep` have both `WordRep` and `IntRep` constructors?

 I had a grep and the only difference I could find is in foreign calls.

 Modifying the program in the description to:
 {{{
 {-# language MagicHash, UnboxedSums, UnliftedFFITypes #-}
 {-# options_ghc -ddump-stg -dppr-debug -fprint-explicit-kinds -ddump-to-
 file -ddump-cmm #-}

 foreign import ccall "bar"
   bar :: Int# -> Int

 mkUnboxedSum :: () -> (# Float# | Int# #)
 mkUnboxedSum _ = (# | 9# #)
 {-# noinline mkUnboxedSum #-}

 foo :: Int
 foo = case mkUnboxedSum () of
   (# | i# #) -> bar i#
   (# f# | #) -> bar 1#
 }}}

 The cmm for the two calls to bar are:
 {{{
            (_s1hz::I64) = call "ccall" arg hints:  [‘signed’]  result
 hints:  [‘signed’] (_c1j0::I64)(_c1j1::I64);
 }}}
 and
 {{{
            (_s1hE::I64) = call "ccall" arg hints:  []  result hints:
 [‘signed’] (_c1j9::I64)(_c1ja::I64);
 }}}

 Presumably these arg hints exist because we can get problems without them?

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14742#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list