Earlier quoted context omitted.
Sure, there is a lot of historical baggage in microprocessors--the BCD stuff and x86-16 support in general only exist for backwards compatibility (although note that BIOS starts up in x86-16). But the reason that Intel keeps adding instructions is, well, because they're useful. > - Why do microprocessors not strive for simplicity, implement only a handful of instructions in an optimized way, with a very small chip fo…
> What you're describing is a GPU I would say I'm describing something halfway between a CPU and a GPU. It's not just an ALU, it's a complete microprocessor, with pipelining, caches, etc. The main difference is that the instruction set is optimized, backward compatibility is no longer a requirement, and redundancy of the architecture is eliminated.
Does a compiler use all x86 instructions? (2010)
131–140 of 198 posts
Re: Does a compiler use all x86 instructions? (2010)
#132> but I have no clue why there are so many lea everywhere. Pointer arithmetic? Which is used for well, ... many things.
Your username is an effective proof that the answer to the title question is "no". :)
Isn't LEA intended to calculate addresses? It seems it also doesn't alter flags and can put its result in any register.
Re: Does a compiler use all x86 instructions? (2010)
#133Earlier quoted context omitted.
Sure, there is a lot of historical baggage in microprocessors--the BCD stuff and x86-16 support in general only exist for backwards compatibility (although note that BIOS starts up in x86-16). But the reason that Intel keeps adding instructions is, well, because they're useful. > - Why do microprocessors not strive for simplicity, implement only a handful of instructions in an optimized way, with a very small chip fo…
> What you're describing is a GPU I would say I'm describing something halfway between a CPU and a GPU. It's not just an ALU, it's a complete microprocessor, with pipelining, caches, etc. The main difference is that the instruction set is optimized, backward compatibility is no longer a requirement, and redundancy of the architecture is eliminated.
Re: Does a compiler use all x86 instructions? (2010)
#134And therein lies the rub. What is the minimum number of instructions a compiler could make use of to get everything done that it needs? I came across an article that says 'mov is turing complete' [1]. But they had to do some convoluted tricks to use mov for all purposes. I think it's safe to say that about 5-7 instructions are all that's needed to perform all computation tasks. But then: - Why do compilers not strive…
Because that would not make CPUs faster or cheaper.
If you think that modern CPUs are large because they implement a lot of instructions, you are completely wrong. The entire machinery needed for executing more than a couple of different instructions is less than 1% of the core. The space is not taken up by decoding tables or ALUs, it's taken up by forwarding networks, registers, and most of all, cache. And all of those are things very much required to make a CPU fast. CPUs have a lot of instructions precisely because the cost of implementing a new instruction is negligible compared to the size of the CPU.
Re: Does a compiler use all x86 instructions? (2010)
#135> but I have no clue why there are so many lea everywhere. Pointer arithmetic? Which is used for well, ... many things.
Pointer creation I think.
Which I assumed to be equivalent to something like: res = ptr_base + offset
Re: Does a compiler use all x86 instructions? (2010)
#136Re: Does a compiler use all x86 instructions? (2010)
#137In general: * x87 floating point is generally unused (if you have SSE2, which is guaranteed for x86-64) * BCD/ASCII instructions * BTC/BTS/related instructions. These are basically a & (1 * MMX instructions are obsoleted by SSE * There's some legacy cruft (e.g., segment management) that's generally unused by anyone not in 16-bit mode. * There are few odd instructions that are basically no-ops (LFENCE, branch predicto…
x86 NaCl uses segments for sandboxing.
Re: Does a compiler use all x86 instructions? (2010)
#138Earlier quoted context omitted.
Modify the backend, or do a binary translation from one to the other and test. If `lea` is the predominate instruction, there might be microcode optimizations that favor `lea` over `movl`. My hunch is that is will be mostly the same barring overflowing the instruction cache. The microps should compile to the same instruction stream.
No, LEA issues as a single micro-op on modern Intel CPUs, but no x86 CPU will merge a sequence of shift and add into a single micro op.
Re: Does a compiler use all x86 instructions? (2010)
#139Re: Does a compiler use all x86 instructions? (2010)
#140Earlier quoted context omitted.
No, LEA issues as a single micro-op on modern Intel CPUs, but no x86 CPU will merge a sequence of shift and add into a single micro op.
How would one find this out? Sounds like it would be fun to figure out how to develop all possible reasonably compact instruction combinations to achieve the same basic block and then compare timings.
Document 4.