https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99405
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The valid C code if it is correct without UB and is pattern matched is definitely better than some intrinsics, it is portable and can be optimized generally sooner and better than the intrinsics. Just be warned that there are many ways how to write not very good rotates, e.g. (x << y) | (x >> (32 - y)) which has UB for y <= 0 or >= 32 etc.