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

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, I think this boils down on which one from

int
foo (int x, int y)
{
  if (x < y)
    return -1;
  else if (x > y)
    return 1;
  else
    return 0;
}

int
bar (int x, int y)
{
  if (x == y)
    return 0;
  else if (x < y)
    return -1;
  else
    return 1;
}

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

generates best code on which architecture (and better in terms of -Os and/or
performance).  Looking at godbolt on various arches, the last is beneficial on
various arches, including x86 (32-bit and 64-bit) and mips, the first maybe on
aarch64 and powerpc*, etc.

Reply via email to