4 ms·
https://www.agner.org/optimize/optimizing_assembly.pdf#page=70 https://www.agner.org/optimize/optimizing_assembly.pdf#page=... TL;DR rule of thumb is that cond
by 10000truths 5y ago
https://www.agner.org/optimize/optimizing_assembly.pdf#page=70 https://www.agner.org/optimize/optimizing_assembly.pdf#page=...
TL;DR rule of thumb is that conditional jump is better than CMOV if the code is part of a dependency chain and the prediction rate is better than 75%.
- mirker 5y agoAre dependency chains complex functions or a few instructions? For example, I see people using ternary expressions “a > b : c ? d”. I’m trying to understand if this is an algorithmic problem or a microarchitecture problem. Are “c” and “d” simple? If both are heavy-duty and approximately the same complexity, evaluating both would be 2x slower than evaluating one, but then you’d have to account for probability of misprediction. Meanwhile, if they are simple, I could imagine the CPU tracking both branch register-level states simultaneously with minimal impact on performance (using register-renaming, for example). In other words, how much better would CMOV be if the hardware was given more micro architecture resources?