[Bug target/51954] __int128_t (and long long on x86) negation can be optimized
crazylht at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Feb 21 06:29:17 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51954
--- Comment #4 from Hongtao.liu <crazylht at gmail dot com> ---
(In reply to Andrew Pinski from comment #2)
> We get this now:
>
> movq %rdi, %rax
> movq %rsi, %rdx
> negq %rax
> adcq $0, %rdx
> negq %rdx
>
> ICC produces:
> xorl %edx, %edx #3.10
> xorl %eax, %eax #3.10
> subq %rdi, %rax #3.10
> sbbq %rsi, %rdx #3.10
> ret #3.10
>
> Which seems even better.
>
> LLVM does produce:
> movq %rdi, %rax
> xorl %edx, %edx
> negq %rax
> sbbq %rsi, %rdx
>
> Which basically combines the addcq and negq together and changes one mov
> into an exor.
Yes, neg rdx = (0 - rdx) = (0 - (rdx + CF)(last def)) = (sbb 0, rdx)
More information about the Gcc-bugs
mailing list