Use common branchless code for `_bfd_mips_elf_sign_extend', typically
avoiding the branch penalty and also reducing code size when inlined in
elfxx-mips.c.
bfd_vma
_bfd_mips_elf_sign_extend (bfd_vma value, int bits)
{
- if (value & ((bfd_vma) 1 << (bits - 1)))
- /* VALUE is negative. */
- value |= ((bfd_vma) - 1) << bits;
-
- return value;
+ bfd_vma sign = (bfd_vma) 1 << (bits - 1);
+ return (value ^ sign) - sign;
}
/* Return non-zero if the indicated VALUE has overflowed the maximum