#995: Needless call to fromInteger for literals
-------------------------+--------------------------------------------------
Reporter: wolfgang | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.7
Severity: minor | Keywords:
Difficulty: Unknown | Testcase:
Architecture: Multiple | Os: Multiple
-------------------------+--------------------------------------------------
For the code below, ghc 6.7 puts the literal 65 in a static closure (S#)
and calls fromInteger on it.
{{{
import Foreign.C ( CChar )
foreign import ccall putchar :: CChar -> IO ()
main = putchar 65
}}}
GHC 6.7 generates the following code; note the static closure Main.lvl and
the call to fromInteger:
{{{
==================== STG syntax: ====================
Main.lvl = NO_CCS GHC.Num.S#! [65];
SRT(Main.lvl): []
Main.main =
\u []
case GHC.Int.fromInteger Main.lvl of ds_sSd {
GHC.Int.I8# ds1_sS2 ->
let {
sat_sSf =
\r [ds2_sS3]
case __ccall_GC putchar [ds1_sS2 ds2_sS3] of
wild_sSe {
(##) ds3_sS7 -> (#,#) [ds3_sS7 GHC.Base.()];
};
} in sat_sSf;
};
SRT(Main.main): []
:Main.main =
\r srt:(0,*bitmap*) [eta_sSc] GHC.TopHandler.runMainIO Main.main
eta_sSc;
SRT(:Main.main): [GHC.TopHandler.runMainIO, Main.main]
}}}
GHC 6.6 just passes the 65 to putchar as an unboxed constant.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/995>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs