3 ms·
Do you know for a fact that Clang's code is faster here, i.e., have you measured it on actual hardware? Armchair performance estimation about "the potential" fo
by tom_mellior 9y ago
Do you know for a fact that Clang's code is faster here, i.e., have you measured it on actual hardware? Armchair performance estimation about "the potential" for something is often wrong...
- raverbashing 9y agoIt might not, but the GCC code has a potential issue in how it does things https://stackoverflow.com/a/41574531 https://stackoverflow.com/a/41574531 (curiously the question is about GCC not doing it, apparently not always)
- aij 9y agoIt's a performance trade off. It's not really surprising that GCC would make different performance trade offs when optimizing for different microarchitectures. (let alone most likely across different versions of GCC) Why would you expect GCC to optimize for Pentium 4 (Netburst) in this day and age? (Especially given that the article is talking about Skylake.)
- raverbashing 9y agoI don't expect it to optimize to P4, are you talking about this? (it's one of the answers to that answer) > The quoted delay of 5 - 6 clocks is much better on later microarchitectures. For example from Sandy Bridge and Ivy Bridge, The Ivy Bridge inserts an extra μop only in the case where a high 8-bit register (AH, BH, CH, DH) has been modified And you see that even on later architectures the point of avoiding AH makes sense (which is the opposite of what that GCC code does)
- rbehrends 9y agoIn a micro benchmark, using the clang version appears to be a bit faster. However, note that code size can also become a relevant concern in larger code bases: Apple, for example, is said to generally build its OS code with -Os rather than -O2 or -O3 (and had -Oz as an even more aggressive custom code size optimization added to gcc back when they still were using it instead of clang).