Hacker News new | ask | show | jobs
by sixthDot 607 days ago
Well it is already the case, for example things like ROR or ROL are generated by optimizers[1] from certain patterns of bitops.

[1]: https://godbolt.org/z/eE1cx9GT4

1 comments

That's more like the opposite, OP wants to tell the compiler what transform to do and have it figure out a solution, but in your example you give the compiler a solution and it works backwards to figure out the intent and rewrite it to a completely different solution.

Most languages do have intrinsics for ROL/ROR at least, which you should generally use instead of relying on optimizer magic. I've certainly run into cases where those magic patterns don't get optimized (looking at you MSVC) but intrinsics always work.