You wrote:

>在 2023-05-26 14:46, Stefan Kanthak 写道:
>> OOPS: why does GCC (ab)use the SSE2 alias "Willamette New Instruction Set"
>> (... ...)
>> OUCH: why does it FAIL to REALLY use SSE2, as shown in the comments on the
>>        right side?
>
> Please stop yelling like that. It makes you look like a naughty pupil.

That's EMPHASISING, kid!

>> 14 instructions in 33 bytes    # 11 instructions in 32 bytes
>>
>> OUCH: why does GCC abuse EBX (and ECX too) and performs a superfluous
>>        memory write?
>
> Apart from the SSE question: You are performing 64-bit arithmetic on a 32-bit
> machine, which GCC isn't good at.

So it's REALLY time to fix that.

> The preferred way to check whether a 64-bit integer is a power of two is to 
> cast it
> to a float, then examine whether its 23-bit mantissa is all zeroes:

Feel free to propose this alternative here (better elsewhere, where you'll
earn less laughter).
But don't forget that this 23-bit mantissa will be all zeroes for quite some
64-bit (and even 32-bit) integers which are no power of 2, for example
0x8000003fffffffff, and that both FILD and CVT2SI2SS only work on SIGNED
integers.

I instead prefer to show that and how GCCs current code generator fails to
optimise properly.

Stefan

Reply via email to