[Bug tree-optimization/99396] std::rotl and std::rotr Does not convert into ROTATE on the gimple level

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Mar 5 03:12:12 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99396

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to cqwrteur from comment #2)
> I would like to see __builtin_cpp_rotl and __builtin_cpp_rotr to allow more
> aggressive optimizations since rotl and rotr are so important for
> cryptography.

You don't need them.
The following code will already produce the rotate instruction:
auto f3(std::size_t v, int t)
{
  return (v<<t) | (v>>(sizeof(v)*8 - t));
}

Note std::rotl/std::rotr has specific behavior dealing with 0 and negative
values and all.


More information about the Gcc-bugs mailing list