13

What is the difference between a machine instruction and a micro-op? I found a following definition here:

A small, basic instruction, used in series to make up a high-level machine instruction

Here is what I found on Wikipedia

In computer central processing units, micro-operations (also known as a micro-ops or μops) are detailed low-level instructions used in some designs to implement complex machine instructions (sometimes termed macro-instructions in this context)

Am I correct in understanding that micro-op is a processor instruction that executes in a given cycle. Say like and ADD, SUB, MUL, ST, LD. Am I missing something?

Any help is appreciated.

4
  • 3
    Micro-ops are basically a way to turn CISC-instructions into RISC-instruction. For example, most RISCs are exclusively load-store (most instructions only work on registers), while CISCs may be able to operate directly on memory-operands. On modern CISC-microarchitectures, the memory-load/store part of an instruction can be decoupled from the ALU-operation by issuing two micro-instructions.
    – user3185968
    Commented Oct 8, 2015 at 22:31
  • 1
    @EOF So basically these are machine instructions. It is just not all of them are visible to the programmer. In other words one a programmer can write some assembly instruction, however a compiler will break it down to 2 or 3 instructions. Am I correct?
    – flashburn
    Commented Oct 8, 2015 at 22:35
  • 2
    Not quite. I'd look at the difference between an ISA and a micro-architecture to understand this. It's not the compiler that turns machine instructions (defined by the ISA) into micro-instructions, it's the CPU itself.
    – user3185968
    Commented Oct 8, 2015 at 22:37
  • @EOF What if we are talking only about RISC architecture? Does micro-op mean the same thing as an instruction or there are exceptions?
    – flashburn
    Commented Oct 8, 2015 at 23:14

1 Answer 1

12

Quite a few years ago it was discovered that RISC was better than CISC. If you wanted a very high speed processor then you wanted all your instructions to be very simple. This allows them to complete in a short period of time and thus a higher clock speed. So Andrew Tanenbaum predicted that "5 years from now no one will be running x86". That was in the 90s.

So what happened? Isn't the x86 (and thus AMD64, also known as x86_64) the best known CISC instruction set? Well, don't underestimate the ingenuity of the Intel (and AMD) engineers. Realising that if they wanted a higher speed processor (back with one core we were hitting > 4GHz in the late 90s) that they couldn't process their complex instructions in one clock cycle. The solution was to use "micro-ops".

Each micro-op would execute in a single clock cycle and would resemble a RISC type instruction. When the processor encountered the CISC instruction it would decode it into several micro-ops, each of which would last one cycle. Thus they could keep their old cruddy instruction set architecture (for backwards compatibility) and have very high clock speeds.

9
  • 2
    So is the definition of micro-ops is only valid for CISC architecture? Can there be micro-ops in a RISC architecture?
    – flashburn
    Commented Oct 8, 2015 at 23:18
  • 3
    Well, "micro-op" doesn't have a well defined definition as far as I'm aware. If you were talking about a RISC instruction set and said micro-op then I'd ask if you were meaning the pipeline stages. But typically, no, micro-op is the break down of a CISC instruction to RISC.
    – dave
    Commented Oct 8, 2015 at 23:20
  • 2
    Are you sure that "each micro-op runs in one cycle"? How do you decompose, say, div into micro-ops of one cycle each?
    – Kerrek SB
    Commented Oct 9, 2015 at 9:06
  • 1
    @hippietrail: It is actually highly related. In What is a microcoded instruction?, I made the point that when we say "a microcoded instruction" when talking about x86 optimization, we mean one where the uops (micro-ops, that should be a Greek mu but I'm lazy) come from the microcode sequencer ROM, rather than being hard-wired into the decoder itself. (On Intel, instruction that decode to 1 to 4 uops can be handled by the decoders without having to indirect to the MS-ROM). But they are the same kind of uops that all go through the back-end. Commented Jul 4, 2020 at 2:01
  • 1
    @hippietrail: See Agner Fog's microarch guide (agner.org/optimize) to better understand this. Also realworldtech.com/merom (Core 2) and realworldtech.com/sandy-bridge for more about internals. Oh also, realworldtech.com/risc-vs-cisc from 2000 looks at how PPro breaks down instructions into uops, vs. RISCs where most instructions are already simple, and only a few every need to be expanded to send multiple things down the pipeline (aka microcoded). Commented Jul 4, 2020 at 2:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.