Hacker News new | ask | show | jobs
by phire 14 days ago
Yeah, not free.

I'm only really arguing that handling flags in OoO designs doesn't require massive amounts of extra "complexity", which is the common argument.

They don't argue that flags add area, or power consumption. Just an unreasonable amount of extra design complexity (and maybe a FMAX limitation) to the extent that OoO μarches would be far better with flags not existing.

Of course flags uses more area (though IMO, probably not much that area). And if it uses area (even a tiny bit), then engineers are probably going to spend time optimising it. Even tiny savings can be put to use elsewhere.

1 comments

Indeed, zero area is better than "small area" to work around a performance bottleneck.

Even one is too many.

But it's not a performance bottleneck.

Flags are a performance advantage. RISC-V needs extra instructions to do the same thing as ARMv8. Or sometimes the same number of instructions, but the compare-and-branch is more heavy (instead of reading an independent 4-bit flags register, it needs to tie up the register ports to do full sized register reads and run compare).

And ARMv8 can use the flags registers to reduce contention on GPRs, while RISC-V is sometimes forced to waste GPRs on emulating flags registers. And it does take a tiny bit more energy to write to a 64-bit register than a 4-bit one.

There are a few cases where compare-and-branch is more optimal than seperate compare and branch instructions... But ARMv8 gets the best of both worlds because it has a set of compare-and-branch instructions too (though some implementations will split that into two μops)

The major advantage of flags is that they give you certain three-input instructions (cmov, addc and ccmp) without requiring a proper three-wide register file.

TBH... I'm not entirely sure the amount of area spent on implementing flags actually provides more benefit than the cost, that would be next to impossible to prove. But they certainly provide more than zero benefit, and IMO it's a quite large advantage.

As said by others on HN, on performant µarchitectures it seems to require significant complexity to fit into the 'standard' optimizations those µarchitecture does, and the one which is often put forward is out of order exectution.