[Bug target/88402] inefficient code generation for mask from CC
amonakov at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Dec 7 19:26:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88402
--- Comment #3 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
However, this may be worthwhile when one of operands is an immediate, as in
that case there's no register pressure increase, and the xor just mutates the
immediate.
Essentially, we'd change e.g.
(signed)a < 0xabcd ? -1ul : 0
to
(a^0x80000000) < 0x8000abcd ? -1ul : 0
and emit a xorl/cmpl/sbbq sequence, plus a mov if a remains live.
Not for 64-bit operands though, where the 64-bits immediates would be costly.
But unfortunately today we don't manage to use the cmp-sbb trick for unsigned
comparison against an immediate, i.e. for
unsigned long baz (unsigned int a)
{
return a < 123 ? -1ul : 0;
}
we emit
xorl %eax, %eax
cmpl $122, %edi
setbe %al
negq %rax
More information about the Gcc-bugs
mailing list