[Haskell-cafe] GHC optimisations
andrewcoppin at btinternet.com
Mon Aug 13 14:05:03 EDT 2007
Does GHC do dead code elimination?
I observe that if you take a module and edit it so that some function is
now no longer exported or called by any exported function, the size of
the *.o file seems to go down. This suggests that dead code within a
single module is eliminated.
However... how about this?
module Foo where
f = ...
g = ...
h = ...
module Main where
main = ...f...
Will the generated executable contain the code for g and h, even though
they aren't called? Or does the unused code get eliminated? How about
the standard libraries?
I read somewhere that if one funtion returns a tuple, and the caller
immediately extracts the values from the tuple, GHC tries to optimise
away the tuple - so it's as if the function can just return multiple
values at once. Is this true? Does it apply only to tuples, or to all types?
More information about the Haskell-Cafe