x86 intrinsics for sale cheap

Guillaume Piolat first.last at spam.org
Thu Jun 1 09:42:39 UTC 2023


On Thursday, 1 June 2023 at 05:26:56 UTC, Cecil Ward wrote:
>>
>> I've been writing asm for over 30 years, the opportunities for 
>> beating modern compilers have gotten vanishingly small for 
>> pretty much everything except for SIMD code. And tbh the 
>> differences between CPUs, ie different instruction latency on 
>> different architectures, means it's pretty much pointless to 
>> chance few percent here or there, since there's a good chance 
>> it'll be a few percent the other way on a different CPU.
>
> I couldn’t agree more. I wrote asm full time for about five 
> years at an operating systems outfit.

I'll join the party as an assembly lover :). There is vanishingly 
few parts where it can make a big difference vs better 
communicating with the backend, I spent two years of my life 
working only on codec optimization with the Intel C++ compiler 
and in the end we had one bit of x86 assembly left, that one was 
using the EFLAGS for multiple jumps from the same op. You can 
also sometimes win if your algorithm fit with the exact register 
count but with "register renaming" I'm not even sure. Often the 
assembly was better than the codegen, but the spilling code the 
compiler insert before and after would make it worse, in addition 
to the lack of optimization. Big positive with asm is the build 
time though!


More information about the Digitalmars-d mailing list