Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#9532 closed task (fixed)

Expose new CLZ/CTZ primops via `Data.Bits` interface

Reported by: hvr Owned by: hvr
Priority: normal Milestone: 7.10.1
Component: libraries/base Version:
Keywords: Data.Bits, report-impact Cc: hvr, ekmett
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: #9340 Differential Rev(s): Phab:D158
Wiki Page:

Description (last modified by hvr)

GHC now provides optimized CLZ/CTZ primops (see #9340), this ticket is about exposing those in a more convenient way.

This was proposed as

and passed (see also proposal summary)

Change History (5)

comment:1 Changed 5 years ago by hvr

Keywords: Data.Bits added
Owner: set to hvr

comment:2 Changed 5 years ago by Herbert Valerio Riedel <hvr@…>

In a8a969ae7a05e408b29961d0a2ea621a16d73d3e/ghc:

Add `FiniteBits(count{Leading,Trailing}Zeros)`

This exposes the newly added CLZ/CTZ primops from
e0c1767d0ea8d12e0a4badf43682a08784e379c6 (re #9340)
via two new methods `countLeadingZeros` and `countTrailingZeros`
in the `Data.Bits.FiniteBits` class.

The original proposal can be found at

Test Plan: successful validate

Reviewers: ekmett, tibbe

GHC Trac Issues: #9532

Differential Revision:

comment:3 Changed 5 years ago by hvr

Description: modified (diff)
Resolution: fixed
Status: newclosed

comment:4 Changed 5 years ago by Herbert Valerio Riedel <hvr@…>

In 3241ac56d371220ed0b9522a86678678532f48bc/ghc:

Remove incorrect property in docstring (re #9532)

The property

  countLeadingZeros . negate = const 0

doesn't generally hold and it's not such a useful property to state, as
it simply follows from "sign-bit == most-significant-bit" for FiniteBits
types which use twos-complement representation for negative values, and
even then it breaks down for 0...

TLDR, remove thinko from documentation of `countLeadingZeros`

comment:5 Changed 5 years ago by hvr

Keywords: report-impact added
Note: See TracTickets for help on using tickets.