[Haskell-cafe] Does GHC compare pointers when eval'ing (==)
alexander.kjeldaas at gmail.com
Wed Aug 20 12:17:46 UTC 2014
On Wed, Aug 20, 2014 at 11:20 AM, Johan Tibell <johan.tibell at gmail.com>
> On Wed, Aug 20, 2014 at 11:05 AM, Johan Holmquist <holmisen at gmail.com>
>> > I think the reason it isn't done is that it's not always an optimization
>> Could you explain when it's not?
> A simple example is when the two values aren't equal, as you'll be doing
> one more branch than you otherwise would.
> The extra branch might also hurt the branch predictor even in the equal
> case, if the branch is hard to predict.
This cost I think we can completely eliminate. If the pointer comparison
is done only for an Eq instance that is statically known to execute N
instructions, then as as long as the cost of all subsequent branch
mispredictions are less than N, then we win, always.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe