Opened 11 months ago

Last modified 9 months ago

#16164 new feature request

Provide bitreverse primop

Reported by: Fuuzetsu Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.6.3
Keywords: newcomer Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

We already have nice primops like byteSwap#, it'd be nice to also have bitreverse.

Clang provides __builtin_bitreverse (http://clang.llvm.org/docs/LanguageExtensions.html#builtin-bitreverse) functions which could be the default. GCC currently doesn't have a built-in (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50481).

One prominent place where this primop could be used is Data.IntSet.Internal where it's implemented as a revNat. Many other libraries also define own versions.

Change History (2)

comment:1 Changed 11 months ago by bgamari

Keywords: newcomer added

Indeed. This would be great to have.

comment:2 Changed 9 months ago by rockbmb

I've got a couple of questions:

  1. Does the inexistence of such an operation in GCC mean such a primop would, at first, only be available when the compiler uses the LLVM backend?
  1. From the understanding I've been gathering, am I right to assume that this primop will be out-of-line?
Last edited 9 months ago by rockbmb (previous) (diff)
Note: See TracTickets for help on using tickets.