[Haskell-cafe] Does GHC compare pointers when eval'ing (==)

Alexander Kjeldaas 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>
> wrote:
>> > 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
> http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140820/0c20f1ad/attachment.html>

More information about the Haskell-Cafe mailing list