4 ms·
> Conditional moves depend on state left over from the last instruction. So, literally exactly the same state that conditional branch instructions depend on? A
by a1369209993 7y ago
> Conditional moves depend on state left over from the last instruction.
So, literally exactly the same state that conditional branch instructions depend on? Aside from implementation details (like >Intel refuses to speculate loads in them<, which, to be fair, might be its own problem), "cmovz D S" is just "jnz skip ; mov D S ; skip:" without the useless branch overhead.
- ncmncm 7y agoBranches are in a different category than moves and ALU ops, for instruction reordering.
- a1369209993 7y ago> Aside from implementation details
- ncmncm 7y agoPerformance is 100% implementation details, from top to bottom. And the only reason anybody uses a cmov instruction is for hoped-for better performance. There is hope that it doesn't squat a precious branch-prediction slot, hope that it doesn't incur a branch misprediction pipeline stall if it's taken, or not taken, hope that fewer instructions translates to fewer clock cycles, hope that what looks like a copy really just does a register-renaming accounting trick, ...