Make Eq type class single method

Sven Panne svenpanne at gmail.com
Wed Oct 20 16:52:19 UTC 2021


Am Mi., 20. Okt. 2021 um 17:17 Uhr schrieb Viktor Dukhovni <
ietf-dane at dukhovni.org>:

> For primitive types CPUs often have both '==' and '/=' instructions,
> and so a direct call to `(/=)` may be more efficient than calling
> `(not .) . (==)`.  [...]


For every native code generator which is worth its salt, this shouldn't
make a difference at all. Swapping the "polarity" of a condition is an
extremely common transformation, which can be used for many reasons. And
even if you don't have anything sophisticated, a simple peephole optimizer
can get rid of the negation operation. And even if all that doesn't help:
Perhaps the negation + condition are fused together in the microcode
operations, depending on your CPU.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20211020/5a01b5e5/attachment.html>


More information about the Libraries mailing list