Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This tool is handy if you want a specific bit shuffle:

https://programming.sirrida.de/calcperm.php

It doesn't always find the optimal solution but it usually gets close.



That's a really cool side. Sad that it doesn't allow duplicate indices. I tried implementing the same thing but with support for duplicates and it was definitely a humbling exercise. I'm curious if there is any formal mathematical theory for this (shifted-off bits would probably make it less elegant than pure rotation)


that page + the book Hacker's Delight are a big part of the reason I am so convinced of this :)

If compilers/languages/standard libraries provided these bit permutations, and it was just something ~everyone had learned, it would be a lot easier to work with bits without needing to come up with the bitwise ops (or use that generator). In addition it would probably make better use of the hardware: sure, people like to pretend that we’re still programming C for PDP11, but modern hardware supports more operations than C has operators for (RISC-V B extension and co have the right idea <3)

Modern compilers are probably pretty good? but I doubt they are perfect at turning code like that in OP into the best instructions. It is probably a bit late for C/C++ though. maaaybe possible to get it into LLVM and Rust.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: