Florian Weimer wrote:
> On s390x, all three variants use conditional
> branches, but the first one is the shortest.
On s390x in 64-bit mode (at least with gcc-4.9), and for argument types
that are smaller than 64 bits, it is possible to avoid the conditional branches
by coding a 63-bit shift:
int lessthan1 (int a, int b)
{
return a < b;
}
int lessthan2 (int a, int b)
{
return - (((long long) a - (long long) b) >> 63);
}
int lessthan3 (int a, int b)
{
return ((unsigned long long) ((long long) a - (long long) b)) >> 63;
}
lessthan2 and lessthan3 produce branch-free code.
But I would not like to put this info into _GL_CMP. Such things belong in
the compiler's machine description. Maybe a newer version of GCC already
has it? (I don't have a newer GCC on this machine.)
Bruno