5 ms·
Your logic would also apply to the compiler back-end to the same measure. Should it emit optimized code then?
by minipci1321 7y ago
Your logic would also apply to the compiler back-end to the same measure. Should it emit optimized code then?
- pjmlp 7y agoYep, it is easier to update the compiler than doing manual clever tricks, specially if the compiler happens to be an AOT/JIT with PGO feedback loop. Most people aren't able to outsmart their compiler optimizers.
- minipci1321 7y ago(This missed my question. Once the compiler is updated to the uArch change, we don't rebuild all binaries out there that were built by the old versions, and their speed is possibly compromised by the uArch change. Should we then even care about emitting binary code optimized for a given uArch, if we can guarantee it is stable in time?)
- pjmlp 7y agoDepends on the use case. One reason mainframes still use bytecode as executable format is that it allows for AOT compiling the world after and OS or hardware upgrade. And there are solutions for doing that to plain native opcodes as well. Finally there is the whole issue that many micro-opmizations, while fun to implement, seldom contribute for visible optimizations of the business case at hand.
- planteen 7y agoThe article is C++, so not sure why you are bringing up AOT/JIT since it doesn't apply here. And clearly there is a large gain possible by doing a calculation rather than a conditional with a high entropy result, otherwise, the article's mentioned speedup wouldn't have happened. A PGO feedback loop isn't going to do anything on a high entropy conditional. I saw a great talk at CppCon 2019 by Andrei Alexandrescu about speeding up std::sort. He does this same trick among others to speed up the C++ std library sort routine. https://www.youtube.com/watch?v=FJJTYQYB1JQ https://www.youtube.com/watch?v=FJJTYQYB1JQ
- pjmlp 7y agoBecause implementation and programming language are not the same thing? Speaking of which, better catch up on the C++ interpreters and JIT related talks from CppCon 2019.
- planteen 7y agoI can't tell if you are trying to troll here. So you reject the notion of branchless coding as a premature optimization because you think it is going to be made irrelevant by a potential future microcode update? Or are you saying that a C++ interpreter/JIT would have made this branchless at run-time, but that optimization isn't made at compile time?
- pjmlp 7y agoThe first one naturally. The tone of my previous remark is that optimization algorithms are orthogonal to programming languages, an language agnostic backend optimizer working on AST and SSA passes doesn't care what the input language was all about.