On 28/05/2023 01:30, Andrew Pinski via Gcc wrote:
On Sat, May 27, 2023 at 3:54 PM Stefan Kanthak <stefan.kant...@nexgo.de> wrote:


         sete    al
         movzx   eax, al                  # superfluous

No it is not superfluous, well ok it is because of the context of eax
(besides the lower 8 bits) are already zero'd but keeping that track
is a hard problem and is turning problem really. And I suspect it
would cause another false dependency later on too.

For -Os -march=skylake (and -Oz instead of -Os) we get:
         popcnt  rdi, rdi
         popcnt  rsi, rsi
         add     esi, edi
         xor     eax, eax
         dec     esi
         sete    al

Which is exactly what you want right?

Thanks,
Andrew

There is also the option of using "bool" as the return type for boolean functions, rather than "int". When returning a "bool", gcc does not add the "movzx eax, al" instruction. (There are some circumstances where returning "int" for a boolean value is a better choice, but usually "bool" makes more sense, and it can often be a touch more efficient.)

David


Reply via email to