https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82498
--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Uroš Bizjak from comment #6) > (In reply to Jack Lloyd from comment #5) > > Jakub thank you very much for your comments, this was helpful for me in > > getting consistent rol/ror generation. > > > > Speaking as a user it's frustrating that Clang and GCC don't just have a > > builtin for rotations like MSVC does, instead you have to guess what > > expressions the optimizer(s) know about. That said there are a lot of > > strange ways to right a rotate and probably GCC doesn't need to know all of > > them. > > You can use __rol{b,w,d,q} and __ror{b,w,d,q} (and their aliases) from > ia32intrin.h. These are standardized; you have to include x86intrin.h header. Well, at least as currently implemented, __ro{l,r}{d,q} require the shift count to be 1 to bitsize - 1. So at least I think we should change their implementation to be like f8 (with & instead of %) which we know we generate optimal code for for any shift count.