New blog post: "Bit-Twiddling: Optimising AArch64 Logical Immediate Encoding (and Decoding)"
Conversation
Replying to
RE “little hand-wavy”: the notion of minimal patterns might be unnecessary. If (x rotate r) == x, and r is coprime to the bit width of x, then I think it follows that (x rotate 1) == x (i.e. x is 0 or ~0). As x is not those values, r must divide the power of two bit width.
1
1
Replying to
As for why x == x rot r and x == x rot s implies x == x rot gcd(r, s): x == x rot r implies x == x rot (i * r) for any integer i (by induction). Extended gcd gives gcd(r, s) == i * r + j * s. Then x == (x rot (i * r)) rot (j * s) == x rot (i * r + j * s) == x rot gcd(r, s).

