3 ms·
> setcc actually does depend on the previous value of the register, because it only comes in the low-byte variants You should be able to break the dependency a
by nayuki 6y ago
> setcc actually does depend on the previous value of the register, because it only comes in the low-byte variants
You should be able to break the dependency and avoid the partial register stall by doing: movzx eax, ax
See: https://stackoverflow.com/questions/41573502/why-doesnt-gcc-use-partial-registers https://stackoverflow.com/questions/41573502/why-doesnt-gcc-... ; https://software.intel.com/en-us/forums/intel-isa-extensions/topic/297441 https://software.intel.com/en-us/forums/intel-isa-extensions... ; https://www.agner.org/optimize/microarchitecture.pdf https://www.agner.org/optimize/microarchitecture.pdf (section 6.8)
- zwegner 6y agoYou're right, but only for pre-Haswell chips, where al etc. are renamed separately. From Haswell onwards, they aren't, and depend on the old value. So movzx eax, al gets you mathematical independence, but not out-of-order independence. There's a bunch more detail in this Stack Overflow question (referenced in the one you linked): https://stackoverflow.com/questions/45660139/how-exactly-do-partial-registers-on-haswell-skylake-perform-writing-al-seems-to https://stackoverflow.com/questions/45660139/how-exactly-do-...