Does a compiler use all x86 instructions? (2010)
pepijndevos.nl
Does a compiler use all x86 instructions? (2010)
1–10 of 198 posts
Re: Does a compiler use all x86 instructions? (2010)
#2Regarding the large number of LEA instructions in x86 code - this is actually a very useful instruction for doing several mathematical operations very compactly. You can multiply the value in a register by 1, 2, 4 or 8, add the value in another register (which can be the same one, yielding multiplication by 3, 5 or 9), add a constant value and place the result in a third register.
Re: Does a compiler use all x86 instructions? (2010)
#3It doesn't, because there are lots of special-purpose x86 instructions that would be more trouble than they're worth to teach a compiler about. For example, instructions for accessing particular CPU features that the C and C++ languages have no concept of (cryptographic acceleration and instructions used for OS kernel code spring to mind). Some of these the compiler might know about via intrinsic functions, but won't…
Re: Does a compiler use all x86 instructions? (2010)
#4Pointer arithmetic? Which is used for well, ... many things.
Re: Does a compiler use all x86 instructions? (2010)
#5Re: Does a compiler use all x86 instructions? (2010)
#6> but I have no clue why there are so many lea everywhere. Pointer arithmetic? Which is used for well, ... many things.
Re: Does a compiler use all x86 instructions? (2010)
#7It doesn't, because there are lots of special-purpose x86 instructions that would be more trouble than they're worth to teach a compiler about. For example, instructions for accessing particular CPU features that the C and C++ languages have no concept of (cryptographic acceleration and instructions used for OS kernel code spring to mind). Some of these the compiler might know about via intrinsic functions, but won't…
X86 is crufty. Of course all old architectures are crufty, and using microcode it's probably possible to keep the cruft from taking up much silicon.
There are also instructions not universally available. A typical compiler will not emit these unless told to do so or unless they are coded in intrinsics or inline ASM.
Re: Does a compiler use all x86 instructions? (2010)
#8Re: Does a compiler use all x86 instructions? (2010)
#9It doesn't, because there are lots of special-purpose x86 instructions that would be more trouble than they're worth to teach a compiler about. For example, instructions for accessing particular CPU features that the C and C++ languages have no concept of (cryptographic acceleration and instructions used for OS kernel code spring to mind). Some of these the compiler might know about via intrinsic functions, but won't…
Re: Does a compiler use all x86 instructions? (2010)
#10> but I have no clue why there are so many lea everywhere. Pointer arithmetic? Which is used for well, ... many things.