x86 shows its age and accumulated cruft here.
RISC-V has test and jump in a single instruction, doing away with flags.
x86 shows its age and accumulated cruft here.
RISC-V has test and jump in a single instruction, doing away with flags.
RISC-V is newer than macro-op fusion, and could account for it possibly being present in implementations.
I do not remember ever seeing the designers of RISC-V actually push macro-op fusion.
The Renewed Case for the Reduced Instruction Set Computer: Avoiding ISA Bloat with Macro-Op Fusion for RISC-V
https://people.eecs.berkeley.edu/~krste/papers/EECS-2016-130...
Yet, it does not push macro-op fusion in implementations. It can either be done, or not done. But RISC-V creates opportunities where it is possible and not harmful to do so, while increasing code density.
>Exploiting this fact, the RV64G and RV64GC effective instruction count can be reduced by 5.4% on average by leveraging macro-op fusion.
It is up to the architects behind implementations to decide when and if to take advantage of the opportunities created by RISC-V's design to do macro-op fusion.
Yes it does. It pushes it as an alternative to adding instructions to the ISA. It says we don’t need these extra instructions because architects can use macro-op fusion to remove the penalty associated with having two instructions rather than one.
They are correct in saying that. x86 didn't have the chance to do so, because back when it was designed, macro-ops were not considered.
Yet whether to fuse or not is still up to microarchitecture architects. RISC-V doesn't push it. Only creates the opportunity where sensible, while increasing code density which benefits everyone.
With RISC-V's current design, you can either not do fusion and eat a penalty, or you can do fusion.
Different ISAs may have a greater or lesser need for fusion, and greater or lesser associated penalty. It seems a little obtuse to insist the ISA doesn't encourage fusion, when other ISAs would avoid a structural penalty for not having fusion, that RISC-V intentionally doesn't try to avoid at all.
Only a small portion of existing RISC-V hardware uses fusion.
This should tell you all you need to know about this mistakenly inferred "penalty" and whether RISC-V forces macro-op fusion into anybody.
As per why fusion helps even when not leveraged: Not allocating encoding space to a unified opcode does, in average over a large body of code, increase code density, as shown in the paper.
This means more code fits in cache, and in hardware this does weight far more than instruction count, which remains low and highly competitive even where fusion isn't leveraged.
Of course, a slow core can easily afford to not have any fusion, but that's a boring question with an obvious answer. The only situation where it makes sense to ask is in the context of a fast core. I think it's pretty clear that competitively-fast RISC-V cores will need significant amounts of fusion.
Anyway, in the context of the original post of cmp+branch, this doesn't even matter, as "separate cmp & branch, fused together if perf desired" and "separate add & load, fused together if perf desired" are the exact same kind of thing, so there's no reason to call one "accumulated cruft" and the other good design. (ok, there are some major problems with x86's flags, but that's primarily just because many operations needlessly update them; other than that, they're just an alternative way to achieve a thing)
I’ll leave others to judge if the quoted paper pushes it and move on.
Macro-op fusion is entirely optional, leveraged by few hardware implementations; Fusion is useful mostly (i.e. exceptions exist) only on mid-range cores.
High end cores prefer to split everything up (unnecessary on RISC-V), whereas low end cores prefer simpler hardware.
Net win in code density weights more in hardware than instruction count, which remains excellent in RISC-V even when the studied microarchitecture does not implement fusion.
(Then RISC-V goes and introduces a flags register for floating-point ops...)
Flags for FP aren't particularly nice, but without them you just can't implement <fenv.h> which software may be expecting. (of course using a global flag for semantics isn't particularly nice either, but hey that's what's been standardized in C)
Sure.
>doing away with temporary register usage
Dubious, as that's up to implementation either way.
A microarchitecture might split it into a load and an add, eliminating any instruction count reduction advantage.
Whereas another microarchiture might take a separate load and add and fuse them, which would free opcode space to be used more effectively elsewhere, resulting in overall code size reduction.
It's a careful balance.
The benefit would be only a tiny improvement in code size, and that's restricted to when the compiler can be absolutely certain that the target CPU is going to be modern enough to support it. So, in practice, for many, many years, this benefit would be almost never reaped.
This is not a new topic in the design of ISAs and their implementations in silicon. Idiom recognition and optimization has long existed in x86, ARM, and I'm sure other old ISA implementations. RISC-V can avoid it by adding dedicated instructions because it's just getting started (relatively speaking), but even so, I'm sure there will be opportunities for idiom recognition and optimization that RISC-V implementers will take.
On RISC-V's fusion idioms, it's not just recognition; they're designed in. Compilers are meant to try and produce them reliably, as if they were a dedicated single opcode.
x86 encoding space already has a lot of clutter in it.
The cost of low code density is that less code fits in cache. This cost is paid in performance, power, area or a combination of them.
x86 is, by many metrics, not a good ISA.
Its value is derived from the software moat, accumulated since the late 1970s.
Thus it isn't immutable. Opcodes can be added and removed.
Yet breaking compatibility with old code would destroy x86's value.
At the expense of code density, and thus hurting PPA (Power, Performance and Area).
Wildly variable opcode length does also complicate the decoder considerably, as it has to find where instructions start and end, an inherently serial operation, and yet decode enough of them to feed an n-wide pipeline.