[GHC] #2070: Record field selectors are not optimized
GHC
trac at galois.com
Mon Jan 28 15:52:36 EST 2008
#2070: Record field selectors are not optimized
------------------------+---------------------------------------------------
Reporter: twanvl | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 6.9 | Severity: normal
Keywords: | Testcase:
Architecture: Unknown | Os: Unknown
------------------------+---------------------------------------------------
It seems that record field selectors are not optimized. Usually this
doesn't matter, but when there are unpacked fields this leaves suboptimal
code. The equivalent code using the data type constructor ''is''
optimized.
For example:
{{{
module Test where
data Test = Test { getR :: {-# UNPACK #-} !Int }
getC (Test a) = a
}}}
Generates the following core (with -O2 -ddump-simpl):
{{{
Test.getR :: Test.Test -> GHC.Base.Int
[RecSel]
[Arity 1
NoCafRefs
Str: DmdType U(L)m]
Test.getR =
\ (tpl_B1 :: Test.Test) ->
case tpl_B1 of tpl1_B2 { Test.Test rb_B4 ->
let {
ipv_B3 [Just S] :: GHC.Base.Int
[Str: DmdType m]
ipv_B3 = GHC.Base.I# rb_B4
} in ipv_B3
}
Test.getC :: Test.Test -> GHC.Base.Int
[GlobalId]
[Arity 1
NoCafRefs
Str: DmdType U(L)m]
Test.getC =
\ (ds_d5Q :: Test.Test) ->
case ds_d5Q of wild_B1 { Test.Test rb_d5S -> GHC.Base.I# rb_d5S }
}}}
After further investigation, it seems that `getR` is not passed through
the optimizer at all, earlier simplifier passes (-ddump-simpl-iterations,
-ddump-cse, -ddump-occur-anal) do not include the function.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2070>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list