News for hackers. Stuff that matters.
Re:What do RISC and CISC mean in 2020? by jcranmer on Friday November 20, 2020 @01:06PM (#25163091)
The better explanation of RISC v CISC is this old discussion from comp.arch: https://yarchive.net/comp/risc_definition.html

In short, the term RISC comes from a new set of architecture designs in the late 80s/early 90s. CISC is not so much an architecture design as it is lacking many of the features. The major features that RISC adds are:

* Avoid complex operations, which may include things such as multiply and divide. (Although note that "modern" RISCs have these nowadays).

* More registers (32 registers instead of 8 or 16). (ARM has 16. So does x86-64.)

* Fixed-length instructions instead of variable-length.

* Avoid indirect memory references or a lot of memory accessing types (note that x86 also does this).

Functionally speaking, x86 itself is pretty close to RISC, especially in terms of how the operations themselves need to be implemented. The implementation benefits of RISC (especially in allowing pipelining) are largely applicable to x86 as well, since x86 really skips the problematic instructions that other CISCs have.

> One of the key ideas of RISC was to push a lot of heavy lifting over to the compiler. That is still the case. Micro-ops cannot be re-arranged by the compiler for optimal execution.

Modern compilers do use instruction scheduling to optimize execution, and instruction scheduling for microcoded execution is well-understood.

> Time is more critical when running micro-ops than when compiling. It is an obvious advantage in making it possible for advance compiler to rearrange code rather than relying on precious silicon to do it.

All modern high-performance chips are out-of-order execution, because some instructions (especially memory!) take longer than others to execute. The "precious silicon" is silicon that's already been used for that reason, whether RISC or CISC.

Re:What do RISC and CISC mean in 2020? by Tuna-Fish on Friday November 20, 2020 @03:56PM (#25164841)
> (ARM has 16. So does x86-64.)

64-bit ARM has 32 GPRs.

> Fixed-length instructions instead of variable-length.

This is the big legacy of RISC that helps "RISC" cpus most against x86. M1 has 8-wide decode, with very few stages and low power consumption. Nothing like it can be done for an x86 cpu. The way modern x86 handles this is typically with a uop cache. But this costs a lot of power, area and only provides full decode width for a relatively small pool of insns -- 4k on modern Zen, for example.

> > One of the key ideas of RISC was to push a lot of heavy lifting over to the compiler. That is still the case. Micro-ops cannot be re-arranged by the compiler for optimal execution.

> Modern compilers do use instruction scheduling to optimize execution, and instruction scheduling for microcoded execution is well-understood.

Compiler-level instruction scheduling is mostly irrelevant for modern OoO architectures. Most of the time the CPU is operating from mostly full queues, so it will be doing the scheduling from the past 10-~16 instructions. Compilers are mostly still doing it out of inertia.

> "precious silicon"

The big difference from that 25 years ago to today is indeed that silicon is now the opposite of precious. We have so many transistors available that we are looking for ways to effectively use more of them, rather than saving precious silicon.

Re:What do RISC and CISC mean in 2020? by avianes on Saturday November 21, 2020 @05:20PM (#25173184)
> Nothing like it can be done for an x86 cpu. The way modern x86 handles this is typically with a uop cache. But this costs a lot of power, area and only provides full decode width for a relatively small pool of insns -- 4k on modern Zen, for example.

The µOP cache is actually not an explanation of how x86 machines perform the decode, it is rather a way to bypass the decode which is expensive and difficult for them.

And the most difficult part is not really the decoding in macro op, the difficulty is to find the boundaries of the instructions to be decoded in parallel.

Because the alignment of each instruction to be decoded depends on the size of the previous instructions, this is a sequential process.

For example, one way to do this is to use instruction size prediction. Intel and AMD hold several patents related to instruction length prediction [1].

[1]: https://patents.google.com/patent/US20140281246A1/en

Re:What do RISC and CISC mean in 2020? by dragontamer on Friday November 20, 2020 @04:24PM (#25165167)
The main issue with linking a discussion from 25 years ago, is that the discussion from is almost irrelevant in today's environment.

The Apple M1 has over 600 reorder buffer registers (while Skylake and Zen are around 200ish). The 16 or 32 architectural registers of the ISA are pretty much irrelevant compared to the capabilities of the out-of-order engine on modern chips.

A 200, 300, or 600+ register ISA is unfathomable to those from 1995. Not only that, but the way we got our software to scale to such "shadow register" sets is due to an improvement in compiler technology over the last 20 years.

Modern compilers write code differently (aka: "dependency cutting"). Modern chips take advantage of those dependency cuts, and use them to "malloc" those reorder buffer registers, and as a basis for out-of-order execution.

While the tech existed back in the 90s for this... it wasn't widespread yet. Even the best posts from back then would be unable to predict what technologies came out 25 years into the future.

Re:What do RISC and CISC mean in 2020? by temac on Friday November 20, 2020 @04:55PM (#25165526)
If I remember correctly the M1 has around 600 reorder buffer entries, and I just checked and Anantech estimate the int register file at around 354 entries. That's still big, but not 600.
Re:What do RISC and CISC mean in 2020? by dragontamer on Friday November 20, 2020 @05:09PM (#25165666)
Ah hah, but there's also 300 FP registers!!

Okay, you got me. I somehow confused the register file with the reorder buffer in the above post. But I think I may still manage to be "technically correct" thanks to the FP register file (even though its not really fair to count those).

Re:What do RISC and CISC mean in 2020? by _chris_ on Friday November 20, 2020 @06:12PM (#25166261)
>The 16 or 32 architectural registers of the ISA are pretty much irrelevant compared to the capabilities of the out-of-order engine on modern chips.

This can have a big effect on memory traffic due to unnecessary moves and stack pops/pushes.

Re:What do RISC and CISC mean in 2020? by dragontamer on Friday November 20, 2020 @06:15PM (#25166288)
All register moves are just renames.

On x86 systems like Skylake or Zen3, it doesn't even use an execution pipeline. Literally zero resources used, aside from the decoder.

Heck, you can perform "xor rax, rax" as much as you'd like, because that's also a rename. It doesn't use any pipeline at all either.

Register renaming (aka: "malloc" a register) is the fastest operation on modern CPUs. That's xor blah,blah, or mov foo, bar, etc. etc.

----------

Its only really an issue if you somehow need more width ("Instruction-level parallelism") than what the architectural registers provide.

And even then... I'm not sure if it matters. There's store-to-load forwarding. So any register you write to L1 cache (that is read back in later on) will be store-to-load forwarded, and the whole memory read will be bypassed anyway.

And even then, L1 cache is 4-clock ticks latency, and issued at the full speed of the chip's load/store units. Even if store-to-load forwarding failed for some reason, L1 cache is damn near the speed of a register.

Re:What do RISC and CISC mean in 2020? by _chris_ on Friday November 20, 2020 @07:15PM (#25166722)
Register moves aren't free, even if you do renaming tricks. They take up fetch bytes, they take up decode slots, they take up a lot more resources than just Regfile/ALU bandwidth.
Re:What do RISC and CISC mean in 2020? by FullyFunctional on Friday November 20, 2020 @07:25PM (#25166772)
You seem to misunderstand. With too few registers you may have to spill to the stack. You can't turn those into register moves in the presence of stores without a very advanced memory disambiguation.
Re:What do RISC and CISC mean in 2020? by gpderetta on Friday November 20, 2020 @08:26PM (#25167136)
technically Zen2 does exactly that. They do still use store/load bandwidth though. I guess that counts as very advanced memory disambiguation.
Re:What do RISC and CISC mean in 2020? by FullyFunctional on Friday November 20, 2020 @09:08PM (#25167340)
All high-end processors do it, but that doesn't come for free (design/verification effort + silicon area/power). Also, the capacity for this is limited to the size of the store buffer so without the needless spills, you can apply all this expensive machinery to more real memory ops.

(A similarly but different debate could be had over all the save/reloads we incur on function entry/exits. 29k and SPARC's register windows were attempts at avoiding those).

Re:What do RISC and CISC mean in 2020? by FullyFunctional on Saturday November 21, 2020 @12:59AM (#25168098)
I failed to add that the stores aren't eliminated by this either so we are also incurring increased memory traffic unnecessarily.
Re:What do RISC and CISC mean in 2020? by jcranmer on Saturday November 21, 2020 @01:24AM (#25168175)
We're talking about stores to the stack, which is likely to not be used by other threads/processors, so all of the values are being modified in a cache entry helpfully held in the Modified state and incurring no bus traffic. It will use up the traffic to/from the cache, though.
Re:What do RISC and CISC mean in 2020? by FullyFunctional on Saturday November 21, 2020 @02:31AM (#25168346)
Yes I did mean cache traffic, poor choice of words, but the point is the same (filling up the store buffers etc).
Re:What do RISC and CISC mean in 2020? by gpderetta on Friday November 20, 2020 @08:24PM (#25167115)
> A 200, 300, or 600+ register ISA is unfathomable to

In addition to the confusion between ROB and register file, register renaming (and the distinction between architectural registers and register files) was already well established in 1995.

Re:What do RISC and CISC mean in 2020? by fanf2 on Friday November 20, 2020 @01:22PM (#25163253)
I am also a fan of John Mashey’s analysis that you linked to! The key thing is that he counts things like instruction formats, addressing modes, memory ops per instruction, registers, and so on. There is a clear separation in the numbers between the RISCs and the CISCs.

What stuck out to me when I first read it 25 years ago is that the ARM is the least RISCy RISC, and x86 is the least CISCy CISC. At that time the Pentium was killing the 68060 and many of the RISCs, and it seemed clear that x86 had a big advantage in the relatively small number of memory ops per instruction.

Re:What do RISC and CISC mean in 2020? by microtherion on Friday November 20, 2020 @06:40PM (#25166486)
I'm not so convinced that x86 really had an architectural advantage. What Intel had was an enormous volume advantage, which allowed them to throw more resources at their designs than the competition.

In fact, Intel had such an advantage that they managed to bet on a completely failed architecture (Itanium) for more than a decade and not only maintain market position but knock out most RISC architectures during the time.

Re:What do RISC and CISC mean in 2020? by jcranmer on Friday November 20, 2020 @09:13PM (#25167365)
Linus has apparently argued that x86 really did have an architectural advantage: https://yarchive.net/comp/linux/x86.html. The argument here is that the CISC nature of x86 forced Intel to innovate microarchitecturally, and those microarchitectural innovations were more important for performance than the RISCy bits that x86 didn't adapt.

I'm not sure I completely buy into the reasoning, but I do believe that Intel (accidentally!) ended up with an architecture that compromised well between RISC and CISC ideas. When they tried to build a shiny RISC architecture, what we got was Itanium, which turned out to be a disaster in no small part because the sufficiently-smart-compiler ideas underlying RISC definitely didn't work out.

Re:What do RISC and CISC mean in 2020? by microtherion on Friday November 20, 2020 @10:25PM (#25167661)
Linus' own career illustrates my point, I think: Transmeta had advantages in low power design at one point, then Intel simply threw more resources at the problem.

> When [Intel] tried to build a shiny RISC architecture, what we got was Itanium, which turned out to be a disaster

That was a shiny VLIW architecture, more or less. The shiny RISC disaster was the 860. And they also had the 432, a fancy CISC disaster, to their name.

Re:What do RISC and CISC mean in 2020? by gpderetta on Friday November 20, 2020 @08:31PM (#25167160)
x86 doesn't have indirect references. Apparently in ~1995 it was to hard to build an OoO engine that could deal with those. Intel just about manged to bolt OoO on x86 while VAX and 680x0 died. AMD also managed to do it in 1996, so it was not just about resources.
Re:What do RISC and CISC mean in 2020? by microtherion on Friday November 20, 2020 @09:10PM (#25167352)
Can you explain what exactly you mean with "indirect references" here?

Edit: To clarify my question — to the best of my knowledge, while the VAX had a higher level of indirection of indirection in instructions than the x86, the 68K has exactly the same level of indirection.

Re:What do RISC and CISC mean in 2020? by jcranmer on Friday November 20, 2020 @09:14PM (#25167372)
Some architectures have instructions such as LDI imm that load MEM[MEM[imm]]--indirect memory references.
Re:What do RISC and CISC mean in 2020? by gpderetta on Saturday November 21, 2020 @09:43AM (#25169974)
I have little knowledge of 68k, but I understand that memory indirect addressing will deference its operand twice [1].

[1] https://en.wikibooks.org/wiki/68000_Assembly#Indirect_addres...

Re:What do RISC and CISC mean in 2020? by microtherion on Saturday November 21, 2020 @01:11PM (#25171449)
Ah yes, you & grandparent are right, I had forgotten about the existence of these modes.
Re:What do RISC and CISC mean in 2020? by fulafel on Friday November 20, 2020 @03:30PM (#25164598)
Aside - Modern general purpouse CPUs tend to be OoO but processors used for demanding computation in things like modems (signal processing/SDR) and GPUs (graphics) tend not to be.
Re:What do RISC and CISC mean in 2020? by idividebyzero on Friday November 20, 2020 @02:17PM (#25163838)
I think it moderately depends on the definition you give it to. If you require RISC to be a load/store architecture, x86 is not even close to be one. Also, aarch64 is a variable-length instructions set and include complex instructions (such as those to perform AES operations). Compiler optimizations are meant to be taken advantage by all architectures, regardless of RISC/CISC.
Re:What do RISC and CISC mean in 2020? by jcranmer on Friday November 20, 2020 @02:45PM (#25164108)
Personally, I think the RISC/CISC "question" isn't really meaningful anymore, and it's not the right lens with which to compare modern architectures. Partially, this is because the modern prototypes of RISC and CISC--ARM/AArch64 and x86-64, respectively--show a lot more convergent evolution and blurriness than the architectures at the time the terms were first coined.

Instead, the real question is microarchitectural. First, what are the actual capabilities of your ALUs, how are they pipelined, and how many of them are there? Next, how good are you at moving stuff into and out of them--the memory subsystem, branch prediction, reorder buffers, register renaming, etc. The ISA only matters insofar as it controls how well you can dispatch into your microarchitecture.

It's important to note how many of the RISC ideas haven't caught on. The actual "small" part of the instruction set, for example, is discarded by modern architectures (bring on the MUL and DIV instructions!). Designing your ISA to let you avoid pipeline complexity (e.g., branch slots) also fell out of favor. The general notion of "let's push hardware complexity to the compiler" tends to fail because it turns out that hardware complexity lets you take advantage of dynamic opportunities that the compiler fundamentally cannot do statically.

The RISC/CISC framing of the debate is unhelpful in that it draws people's attention to rather more superficial aspects of processor design instead of the aspects that matter more for performance.

Re:What do RISC and CISC mean in 2020? by brandmeyer on Friday November 20, 2020 @05:03PM (#25165601)
> It's important to note how many of the RISC ideas haven't caught on.

2-in, 1-out didn't, either. Nowadays all floating-point units support 3-in, 1-out via fused multiply-add. SVE provides a mask argument to almost everything.

Re:What do RISC and CISC mean in 2020? by klelatti on Friday November 20, 2020 @03:48PM (#25164768)
Unless you're using a definition I'm not familiar with aarch64 isn't a variable length instruction set - here's Richard Grisenthwaite Arm's lead architect introducing ARMv8 - the slide here confirms "New Fixed Length Instruction Set":

https://youtu.be/GBeEEfmJ3NI?t=570

Re:What do RISC and CISC mean in 2020? by idividebyzero on Friday November 20, 2020 @04:34PM (#25165282)
I understand that they refer to it as a fixed-length instruction set, it's correct, note though that not all ARMv8 instructions are 4 bytes long. Indeed, some instructions that are met together are fused to a single one, or SVE, for instance, introduces prefix; so practically, this means that sometimes instructions can be 8 bytes long.
Re:What do RISC and CISC mean in 2020? by brandmeyer on Friday November 20, 2020 @05:05PM (#25165621)
Macro-op fusion of the MOVW/MOVT family doesn't count. At the time of that presentation, SVE didn't exist. Even now, the masked move instruction in SVE can also stand on its own as a single instruction and sometimes it does get emitted as its own uop.
Re:What do RISC and CISC mean in 2020? by klelatti on Friday November 20, 2020 @04:47PM (#25165457)
Thanks, yes of course. I guess probably fair to say that philosophically it's fixed-length, in way that the original Arm was RISC, i.e. with some very non RISC-y instruction. Very different to x86 though.
Re:What do RISC and CISC mean in 2020? by Tuna-Fish on Friday November 20, 2020 @03:57PM (#25164850)
64-bit Arm is fixed width. Modern 32-bit Arm was not fixed width, as Thumb-2 was widely used.
Re:What do RISC and CISC mean in 2020? by marcan_42 on Friday November 20, 2020 @11:11PM (#25167823)
The main difference is x86 decode is hell to parallelize, as you have no idea where instructions start or end. It's a linear dependency chain of instruction lengths, an antipattern in the modern parallel processing world. Modern x86 CPUs have to use a large number of tricks and silicon to deal with this decently.

While even with Thumb-2, you can at worst just try decoding an instruction at every halfword. At worst you throw away half of the results if they are the second half of an instruction that was already taken care of. If you tried to do the same thing with x86 you'd throw away many more results, trying to decode (much more complex encodings) at every byte.

Re:What do RISC and CISC mean in 2020? by jcranmer on Saturday November 21, 2020 @01:39AM (#25168222)
Is it really so hard to find instruction length in x86? State machines are associative, and therefore you can build a reduction tree for parallel processing of them. And the state machine itself isn't too bad: it's mostly prefixes, and figuring out if the opcode uses a ModR/M byte (which most do) or has an immediate operand. And while x86 does have a nasty habit of packing multiple instructions into a single opcode (via specific register values in the ModR/M byte), I believe all of them would share the same behavior in the immediate operand effects.

I suspect that in one pipeline stage, you could at least resolve the entire cacheline into the individual instruction boundaries that can be simultaneously issued into uops, if not having the entire instruction decoded into the hardware fields. You wouldn't know if register 7 referred to a general purpose register, or a debug register, or an xmm reg, or whatnot, but you'd probably know that it was a register 7.

Re:What do RISC and CISC mean in 2020? by Tuna-Fish on Saturday November 21, 2020 @02:50AM (#25168392)
And after you know each instruction boundary, now you have to do a massive mux from positions in the cache line to separate decoders. As I understand, that's a big part of the problem, and essentially costs more than a single pipeline stage.
Re:What do RISC and CISC mean in 2020? by gpderetta on Friday November 20, 2020 @08:34PM (#25167172)
x86 is certainly not RISC by any sane definition. It is still one of the least complex historical CISCs.
Re:What do RISC and CISC mean in 2020? by qwerty456127 on Friday November 20, 2020 @04:33PM (#25165261)
> Avoid complex operations, which may include things such as multiply and divide.

How can this possibly make sense? Almost every application multiplies and divides all the time anyway. It usually is a good idea to implement frequently used operations in hardware because hardware implementation is always more efficient than software implementation, isn't it?

Re:What do RISC and CISC mean in 2020? by fulafel on Saturday November 21, 2020 @03:50AM (#25168552)
> Almost every application multiplies and divides all the time anyway

This is the crux of the RISC philosophy: Most things happen "all the time" in processors since they do a lot of things very fast, but what really matters is how often. The quantitative approach is actually looking at what instruction mix and its fastest implementation given to a reasonably competent compiler prouduces fastests overall results (given that simpler chips could be clocked faster, have shorter pipelines so better branching, leave more space for cache, etc).

The thing about multiplicationsan divisions, besides being slow in silicon, is that you can actually cover a surprisingly big part of application code multiplies with just a couple of shifts and adds. This is especially true for constant multiply or a known smallish range of multipliers, which optimizers are good at discovering.

But of course the transistor budgets and tradeoffs were different in the days of early RISC. Still, even the relatively recent RISC-V elided multiply and divide from the base instruction set.

Re:What do RISC and CISC mean in 2020? by aidenn0 on Friday November 20, 2020 @07:11PM (#25166702)
Many of the "true RISC" cpus that could dispatch 1 ALU instruction per clock cycle had instructions for accelerating division; it would do one round of division and could be called in a loop to implement a full divide.

Note that dividing by a constant does not need a divide instruction, so it's only when dividing by a variable that division is needed. Even on CISC machines of the time division instructions were so slow that programmers would go out of their way to avoid using them.

Re:What do RISC and CISC mean in 2020? by wk_end on Friday November 20, 2020 @08:54PM (#25167286)
Even in hardware, multiplication and division are much slower than addition or subtraction. The speed you can run your processor at is bound by the slowest thing in your data path. So if you want a native division instruction, either you slow the CPU down so that a division can execute in a single cycle or you make the instruction run over the course of multiple cycles, complicating your pipeline.

The original RISC guys were dogmatic (or, more generously, they were researchers exploring the possibilities of an idiosyncratic dogma), and their dogma dictated that:

1. a simple - and fully exposed - pipeline could be more fully exploited by programmers and compilers and served as a better use of chip real estate, so everything should run in a single cycle

2. keeping your data path simple so that you could ramp up the clock speed was the key to overall speed

So they chose to scrap multiplication and division altogether. In practice, much of this probably turned out to be a bad idea, at least as chip technology has improved (and memory speed relatively stagnated), and that brings us to today.

Re:What do RISC and CISC mean in 2020? by marcan_42 on Friday November 20, 2020 @11:15PM (#25167839)
Division is still optional in ARM; their smallest core (Cortex-M0) does not have it. That makes perfect sense for that class of embedded core; to be honest, division by a variable is a very rare operation in embedded code (division by a constant is multiplication by the reciprocal, so that doesn't need a division instruction).
Re:What do RISC and CISC mean in 2020? by Asooka on Friday November 20, 2020 @05:08PM (#25165649)
That was for back when CPUs didn't really have native division or multiplication. So a mul or div would literally be like calling a function to do it using other arithmetic instructions, except the function is stored in the CPU. Which goes against the RISC philosophy and makes the CPU more complex for not much gain.
Re:What do RISC and CISC mean in 2020? by qwerty456127 on Friday November 20, 2020 @06:30PM (#25166412)
> So a mul or div would literally be like calling a function to do it using other arithmetic instructions, except the function is stored in the CPU.

Wouldn't this be times (if not orders of magnitude) faster than loading it in software anyway? I believe it was one of the most frequently used functions, hard or soft.

Re:What do RISC and CISC mean in 2020? by marcan_42 on Friday November 20, 2020 @11:19PM (#25167849)
Multiplication is reasonably common. Once you have multiplication by a constant you get division by a constant for free, so that leaves division by a variable. That is a very rare operation in non-mathy code, and usually for math you'd end up with floating point division anyway which is a whole different ball game (good code anyway; people writing for modern CPUs will of course throw integer division and modulo around without second thought, but the vast majority of the time you can avoid those operations and run faster).
Re:What do RISC and CISC mean in 2020? by undersuit on Friday November 20, 2020 @06:39PM (#25166480)
>I believe it was one of the most frequently used functions, hard or soft.

Left Shift and Right Shift are extremely hurt by this comment.

Re:What do RISC and CISC mean in 2020? by qwerty456127 on Friday November 20, 2020 @04:36PM (#25165311)
> Functionally speaking, x86 itself is pretty close to RISC,

AFAIK some x86 implementations (e.g. AMD K6-3) had RISC cores and translation units.