https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98713
Roger Sayle <roger at nextmovesoftware dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |roger at nextmovesoftware dot com --- Comment #2 from Roger Sayle <roger at nextmovesoftware dot com> --- My first impression is that this isn't a bug, it's a feature. In an optimizing compiler, the user specifies the computation to be performed and the compiler selects the implementation. Hence "x+0" isn't a user request to perform an addition. Perhaps David could provide more information on why a branch implementation is required/preferred (for example on which target)? On generic x86_64, I believe the code currently generated is both smaller and faster. Assuming "neg eax" takes about the same time as "test edi,edi", and that "cmovs" takes about the same time as (either branch) of "js". As a workaround a branch version can be implemented in inline assembly using __asm, but I'm still hazy as to why this would be desirable.