3 ms·
I've recently become convinced intrinsics have a strong reason to at least try them after I rewrote something that was using inline ASM into intrinsics 1:1, and
by rincebrain 4y ago
I've recently become convinced intrinsics have a strong reason to at least try them after I rewrote something that was using inline ASM into intrinsics 1:1, and got a not-insignificant speedup, evidently solely because the compiler was better at optimizing it than I was.
- ygra 4y agoInline ASM might be somewhat opaque to the compiler and interfere with optimization in general. It's not in the IR format that the optimizer uses; register allocation is probably up to the ASM code, not the compiler's choice, perhaps forcing it to either skip optimizing a complete function, just the block in which inline ASM appears, or even to add additional code outside the block to make it run correctly.
- rincebrain 4y agoAIUI compilers treat inline ASM as an entirely opaque block they cannot mutate or assume much about, so if you're inlining 100 lines of ASM, you will get the ASM you asked for, for better or worse. (Treating it as completely opaque is, I believe, also why you can get away with things like inlining AVX2 ASM on an -mno-avx2 build, for example.)