Does a compiler use all x86 instructions? (2010)
71–80 of 198 posts
Re: Does a compiler use all x86 instructions? (2010)
#72There are instructions that would almost never be useful. See Linus's rant on cmov http://yarchive.net/comp/linux/cmov.html The tl;dr is that it would only be useful if you are trying to optimize the size of a binary.
Re: Does a compiler use all x86 instructions? (2010)
#73The article assumes that no software in bin is written natively in asm or has asm blocks or linked objects... which seems a bit out there.
Re: Does a compiler use all x86 instructions? (2010)
#74The article assumes that no software in bin is written natively in asm or has asm blocks or linked objects... which seems a bit out there.
My thought was that most binary distributions probably use very conservative configuration that will generate code that compatible with very old processors, and that you would therefore not see much use of modern instructions in /bin. This is one of the selling points of compile-yourself distributions like Arch/Gentoo: you know what processor you're running on, so you can take full advantage of its features.
Re: Does a compiler use all x86 instructions? (2010)
#75Re: Does a compiler use all x86 instructions? (2010)
#76Earlier quoted context omitted.
Since P6, Intel's CPUs have used a RISC like core with a very heavy decoder that translates x86 CISC instructions to run on the internal ISA. With that in mind, do older or lesser used instructions actually perform poorly or are they just the wrong choice but actually preferred for other scenarios?
Some legacy instructions are too complex and infrequently used so they are microcoded and run much slower.
Some instructions may end up slow when the microcode isn't updated to take advantage of the latest processor iteration (I recall this happened to rep movs at some point, which gave it its bad reputation, even though it was fixed). That probably happens often for legacy instructions.
Re: Does a compiler use all x86 instructions? (2010)
#77Earlier quoted context omitted.
Some legacy instructions are too complex and infrequently used so they are microcoded and run much slower.
Nearly all x86_64 instructions are microcoded on modern Intel and AMD CPUs. That does not mean they're slow. Some instructions may end up slow when the microcode isn't updated to take advantage of the latest processor iteration (I recall this happened to rep movs at some point, which gave it its bad reputation, even though it was fixed). That probably happens often for legacy instructions.
Re: Does a compiler use all x86 instructions? (2010)
#78What 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 to simplify their code-gen phase, or enable themselves to do advanced instruction-level program analysis, or both?
- Why do microprocessors not strive for simplicity, implement only a handful of instructions in an optimized way, with a very small chip footprint, to be followed by proliferation of cores (think 256-core, 512-core, 1024-core).
Besides the completely valid reason that humans tend to overly-complicate their solutions, and then brag about it, the main reason is historical baggage and the need for backwards compatibility.
Intel started with a bad architecture design, and only made it worse decades after decades, by piling one bunch of instructions over another, and what we now have is a complete mess.
On the compiler front, the LLVM white-knights come along and tell people 'you guys are wimps for using C to do compilers. Real men use monsters like C++, with dragons like design-patterns. No one said compiler programming is supposed to be as simple as possible.'
To those lamenting javascript and the web being broken, wait till you lift the rug and get a peek at the innards of your computing platform and infrastructure!
Re: Does a compiler use all x86 instructions? (2010)
#79My question is if compilers use "new" x86 instructions, as then the program won't work at all on old systems. For example, if Intel decided today that CPUs need a new "fast" hashing opcode (I don't know if they actually do), a compiler can't compiles to it, as programs won't work on older computers. Is it like the API cruft in Android, where "new" Lollipop APIs are introduced for 10 years from now, when no one uses a…
Re: Does a compiler use all x86 instructions? (2010)
#80And 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…