4 ms·
Suppose you want to support strings and have a string comparison instruction. You might think that "it's done in the hardware", so it's blindingly fast. It isn'
by userbinator 11y ago
Suppose you want to support strings and have a string comparison instruction. You might think that "it's done in the hardware", so it's blindingly fast. It isn't, because the hardware still has to access memory, one word per cycle. A superscalar/VLIW assembly loop would run just as quickly; the only thing you'd save is a few bytes for instruction encoding.
Actually if you've actually looked at things like SSE memory copying/comparison routines, it's not "a few bytes", it's more like a factor of 100x+. REP MOVSB is 2 bytes; a SSE memcpy, highly unrolled - incidentally, also a bad idea for modern CPUs - is easily a few hundred. I've seen ones over a kilobyte(!) The former is essentially the same speed as the latter, but makes for significantly less instruction cache utilisation, which is increasingly important today.
You see, RISC happened for a reason.
When memory bandwidth was not the bottleneck, it was a good idea. Now, not so much. Even ARMs which are considered "RISC" are growing into uop-decoding decoupled OoO machines like x86, and adding more instructions with each new generation. I like to mention this article, where the "purest" RISC, MIPS, turns out to be the least power-efficient:
http://www.extremetech.com/extreme/188396-the-final-isa-showdown-is-arm-x86-or-mips-intrinsically-more-power-efficient http://www.extremetech.com/extreme/188396-the-final-isa-show...
I'd say that CPUs are certainly getting more high-level and CISCy, but not in the same way as their original proponents imagined. If you don't think so, try beating POPCNT, CRC32, AESENC, etc. with a sequence of simpler instructions...
- renox 11y agoI find strange your point about ARM vs MIPS given that ARMv8 seems much more 'MIPSy' than previous ARM ISAs..
- sklogic 11y agoWhy? It's very intentionally not MIPSy. ARMv8 removes anything that may dictate any microarchitecture decisions, while MIPS exposes it in an ISA (delay slots and all that). Even predication had been killed for this reason (it's not good for OoO anyway).
- _yosefk 11y agoYeah, but * mips didnt have predication to begin with * arm didnt have delay slots to begin with * and then afaik 64b arm uses more registers and removes shifter operands So definitely more mipsy.
- hga 11y agoWhen memory bandwidth was not the bottleneck, it was a good idea. That plus the earlier period in VLSI when there was an extreme premium on the number of gates you put on a single die. If you could fit an entire simplified CPU on a small die you could win big, and this advantage continued as FPUs, cache, and more and more cache were added. Nowadays gates aren't exactly free, but dies are constrained by other considerations like power and size (yield) balanced against what more gates will gain you. Outside of tiny microcontrollers, I don't think any one is obsessing over the issues that limited the 1978 8086 to 29,000 transistors, or the 1979 68000 to 68,000 (https://en.wikipedia.org/wiki/Transistor_count https://en.wikipedia.org/wiki/Transistor_count).
- Tuna-Fish 11y agoThere are a lot of new kind of more complicated instructions, but they very much follow the basic RISC principles. That is, instructions that do any kind of math take in a few register operands, output into a register, and do so quickly and do not touch any external state. They do not do some math, wait on memory, and do more math based on it, they do not access complex internal state, etc. The only exception to this are the x86 string instructions, and even they store all their state in registers during interrupts. Basically, RISC at some point meant {reduced instruction set} computer, now it means {reduced instruction} set computer.
- rasz_pl 11y ago"Suppose you want to support strings and have a string comparison instruction. You might think that "it's done in the hardware", so it's blindingly fast. It isn't, because the hardware still has to access memory," well, there is this: http://www.micron.com/about/innovations/automata-processing http://www.micron.com/about/innovations/automata-processing