Bits, Math and Performance(?)

50% bits, 50% math (allegedly)

Tuesday, 28 July 2026

Asking a bit-permutation what it does (and cloning it)

›
Given some black-box permutation that operates on an array of integers, it's easy to find out what the permutation does: feed it an ...
Friday, 26 June 2026

Fenwick trees for products mod 2ⁿ

›
After browsing some articles about Fenwick trees (aka Binary Indexed Trees) and seeing remarks such as "let f be some group operat...
Sunday, 7 June 2026

What is abs(x - y)

›
What is abs(x - y) , why do I even bother asking a question like that, much less answer it? Trust me, it's more interesting than it ...
Monday, 22 December 2025

Computing 264 mod N, where N is a u64

›
Before we go any further, the answer is (usually) -N % N . "Usually", because for example MSVC with "SDL checks" ...
Friday, 6 June 2025

From Boolean logic to bitmath and SIMD: transitive closure of tiny graphs

›
Let's say that we have a graph of at most 8 nodes (you can also think of it as a relation between 8 things), represented as an 8 by ...
Tuesday, 10 December 2024

Bit-permuting 16 u32s at once with AVX-512

›
The basic trick to apply the same bit-permutation to each of the u32 s is to view them as matrix of 16 rows by 32 columns, transpose it...
Sunday, 10 November 2024

Histogramming bytes with positional popcount (GF2P8AFFINEQB edition)

›
A while ago, after some back and forth on twitter/X with @corsix , I dropped some implementation of byte histogramming without explain...
Thursday, 22 August 2024

Enumerating identities, part 2

›
Part 2 of Enumerating all mathematical identities (in fixed-size bitvector arithmetic with a restricted set of operations) of a certain ...
Tuesday, 18 June 2024

Sorting the nibbles of a u64

›
I was reminded (on mastodon) of this nibble-sorting technique (it could be adapted to other element sizes), which I apparently had only ...
Tuesday, 4 June 2024

Sharpening a lower bound with KnownBits information

›
I have written about this before , but that was a long time ago, I've had a lot more practice with similar things since then. This ...
Monday, 3 June 2024

Multiplying 64x64 bit-matrices with GF2P8AFFINEQB

›
This is a relatively simple use of GF2P8AFFINEQB . By itself GF2P8AFFINEQB essentially multiplies two 8x8 bit-matrices (but with trans...
Tuesday, 28 May 2024

Implementing grevmul with GF2P8AFFINEQB

›
As a reminder, grev is generalized bit-reversal , and performs a bit-permutation that corresponds to XORing the indices of the bits of ...
Thursday, 4 April 2024

Enumerating all mathematical identities (in fixed-size bitvector arithmetic with a restricted set of operations) of a certain size

›
Once again a boring-but-specific title, I don't want to clickbait the audience after all. Even so, let's get some "disclaim...
Saturday, 9 March 2024

The solutions to 𝚙𝚘𝚙𝚌𝚗𝚝(𝚡) < 𝚝𝚣𝚌𝚗𝚝(𝚡) and why there are Fibonacci[n] of them below 2ⁿ

›
popcnt(x) < tzcnt(x) asks the question "does x have fewer set bits than it has trailing zeroes". It's a simple quest...
Wednesday, 17 January 2024

Partial sums of popcount

›
The partial sums of popcount , aka A000788: Total number of 1's in binary expansions of 0, ..., n can be computed fairly efficiently...
›
Home
View web version

About Me

Harold
View my complete profile
Powered by Blogger.