Square root of bitwise NOT
The square root of bitwise NOT, if it exists, would be some function f such that f(f(x)) = not x, or in other words, f²(x) = not x. It is similar in concept to the √NOT gate in Quantum Computing, but...
View ArticleInformation on incrementation
Defining incrementJust to avoid any confusion, the operation that this post is about is adding 1 (one) to a value: $$\text{increment}(x) = x + 1$$ Specifically, performing that operation in the domain...
View ArticleThe range a sum cannot fall within
.nobr { white-space: nowrap; } Throughout this post, the variables A, B, and R are used, with R defined as R = A + B, and A ≤ B. Arithmetic in this post is unsigned and modulo 2k. Note that A ≤ B is...
View ArticlePartial sums of blsi and blsmsk
blsi is an x86 operation which extracts the rightmost set bit from a number, it can be implemented efficiently in terms of more familiar operations as i&-i. blsmsk is a closely related operation...
View ArticleInteger promotion does not help performance
There is a rule in the C language which roughly says that arithmetic operations on short integer types implicitly convert their operands to normal-sized integers, and also give their result as a...
View ArticleBit-level commutativity and "sum gap" revisited
.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } In an earlier post, bit-level commutativity, it was shown that addition is...
View ArticleWeighted popcnt
.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } Since I showed the code below on Twitter, and some people understood it...
View ArticleColumn-oriented row reduction
.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } blockquote footer { background-color: #F5F5F5; clear: both; } blockquote:before { color: #ccc; content: open-quote;...
View Article(Not) transposing a 16x16 bitmatrix
.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } blockquote footer { background-color: #F5F5F5; clear: both; } blockquote:before { color: #ccc; content: open-quote;...
View Articlegrevmul
.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } blockquote footer { background-color: #F5F5F5; clear: both; } blockquote:before { color: #ccc; content: open-quote;...
View ArticleSome ways to check whether an unsigned sum wraps
.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } When computing x + y, does the sum wrap? There are various ways to find...
View ArticlePropagating bounds through bitwise operations
.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } blockquote footer { background-color: #F5F5F5; clear: both; } blockquote:before { color: #ccc; content: open-quote;...
View ArticlePermuting bits with GF2P8AFFINEQB
.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } It's no secret that GF2P8AFFINEQB can be tricky to think about, even in...
View ArticlePartial 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 with some mysterious code found through its OEIS entry (see the link...
View ArticleThe solutions to 𝚙𝚘𝚙𝚌𝚗𝚝(𝚡)
.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } popcnt(x) < tzcnt(x) asks the question "does x have fewer set bits than...
View ArticleEnumerating all mathematical identities (in fixed-size bitvector arithmetic...
.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } Once again a boring-but-specific title, I don't want to clickbait the...
View ArticleImplementing grevmul with GF2P8AFFINEQB
.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } As a reminder, grev is generalized bit-reversal, and performs a...
View ArticleMultiplying 64x64 bit-matrices with GF2P8AFFINEQB
.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } This is a relatively simple use of GF2P8AFFINEQB. By itself GF2P8AFFINEQB...
View ArticleSharpening a lower bound with KnownBits information
.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } I have written about this before, but that was a long time ago, I've had a...
View ArticleSorting the nibbles of a u64
.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } I was reminded (on mastodon) of this nibble-sorting technique (it could be...
View ArticleEnumerating identities, part 2
.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } Part 2 of Enumerating all mathematical identities (in fixed-size bitvector...
View ArticleHistogramming bytes with positional popcount (GF2P8AFFINEQB edition)
.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } A while ago, after some back and forth on twitter/X with @corsix, I...
View ArticleBit-permuting 16 u32s at once with AVX-512
.nobr { white-space: nowrap; } blockquote { background-color: #EEE; clear: both; } img { max-width: 100%; max-height: 100%; } The basic trick to apply the same bit-permutation to each of the u32s is...
View ArticleFrom 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 8 Boolean matrix, and we want to compute its transitive closure. A...
View ArticleThe non-problem of unsigned integers in Java
div:has(> blockquote) { background-color: #ededed; margin: 10px auto; padding: 15px; border-radius: 5px; } blockquote p::before { content: "\201C"; } blockquote p::after { content: "\201D"; }...
View Article