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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The pattern is written for what people normally do, i.e. use int/unsigned int
shift count rather than unsigned char.

BTW, in any case, this isn't portable rotate that you get efficient code for
anyway, you get much better code if you don't special case the 0:
#include <limits.h>
#include <stdint.h>

uint32_t
baz (uint32_t x, unsigned y)
{
  y %= CHAR_BIT * sizeof (uint32_t);
  return (x << y) | (x >> (-y % (CHAR_BIT * sizeof (uint32_t))));
}

is what the compiler will pattern match and generate optimal code for, but if
it doesn't is still efficient and without branches.

Reply via email to