https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43883
Andrew Pinski changed:
What|Removed |Added
Severity|normal |enhancement
--- Comment #8 from Andrew P
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43883
--- Comment #7 from Andrew Pinski ---
4.7 produces:
shr rsi, 63
mov rax, rdi
xor edi, edi
add rax, rsi
xor r10d, r10d
mov r9, rax
mov rdx, r10
and r9d
--- Comment #6 from svfuerst at gmail dot com 2010-04-30 20:30 ---
For posterity, I might as well note that with the sbb added on the end we don't
need the initial mov instruction if we do some register renaming. This leaves
the, hopefully optimal this time, five-instruction fragment as
--- Comment #5 from ubizjak at gmail dot com 2010-04-30 19:00 ---
(In reply to comment #4)
> Argh, the sar trick doesn't work when the number is negative and even. Sorry
> about the extra noise.
>
> This leaves as the best code:
> mov%rsi,%rdx
> shr$0x3f,%rdx
> lea(%rdi,%rd