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

--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
We could file an x86 backend enhancement request based on those comments,
int
foo (int x, int y)
{
  return x << (y & 31);
}

int
bar (int x, int y)
{
  return x << (32 + y);
}

int
baz (int x, int y)
{
  return x << (-y & 31);
}

int
qux (int x, int y)
{
  return x << (32 - y);
}
where we optimize away the & 31 masks, but actually not the additions of 32. 
It actually doesn't change anything on the number of instructions in this case,
but bar needs 1 more bytes than equivalent foo and qux even 3 more bytes than
equivalent baz.

Reply via email to