[COMMITTED] math: Fix non-portability in the computation of signgam in lgammaf

Paul Eggert eggert@cs.ucla.edu
Tue Nov 26 04:43:15 GMT 2024


On 2024-11-25 12:22, Vincent Lefevre wrote:
> But for the most common cases (fx >= 0, which should be likely),
> I suppose that it would be slower (though I'm wondering whether
> this is noticeable).

Athough it's indeed not a big deal, statically the proposed code is a 
clear win on x86-64, as it generates only 27 bytes in code space, 
compared to the current 48 bytes. Dynamically it's closer, but even 
assuming the argument is always nonnegative the current and proposed 
code both execute the same number (27) of bytes' worth of instructions; 
and although the proposed code executes one more instruction, once that 
gets converted to micro-ops I doubt whether it'd be any slower. Plus, 
the proposed code has no conditional branches and this avoids polluting 
the branch predictor.


More information about the Libc-alpha mailing list