4 ms·
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/eE1c
by sixthDot 2y 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 https://godbolt.org/z/eE1cx9GT4
- jsheard 2y agoThat'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.