[GHC] #10120: Unnecessary code duplication from case analysis
GHC
ghc-devs at haskell.org
Sat Feb 28 16:34:20 UTC 2015
#10120: Unnecessary code duplication from case analysis
-------------------------------------+-------------------------------------
Reporter: bgamari | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.1-rc2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by bgamari):
I'm unsure of whether it's reasonable to expect the compiler to know that
it's not worth specializing the case analysis on the character `c`. For
instance, `do_something` may also branch on the character; if the compiler
specialized then it could eliminate the branch inside of `do_something`.
However, it would be nice if the compiler gave us the tools to force the
sort of behavior we want. For instance, consider an identity-like function
`evalThis :: a -> a`. This would prevent the compiler from "breaking up"
the term in the course of optimization. For instance,
{{{#!hs
f c = let pred = evalThis $ c == 'a' || c == 'b' || c == 'c' :: Bool
in case pred of
True -> ...
False -> ...
}}}
would prevent the compiler from using the "insides" of `pred` in the case
analysis, ensuring that somewhere in the resulting executable there would
be boolean value `pred` which would then be matched against. This is
obviously a pretty big hammer, but it might be nice to have every once in
a while.
Perhaps such a facility already exists?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10120#comment:10>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list