On Sun, 14 Jan 2018 19:59:11 +0100, "Walter H."
<
Walter...@nospicedham.mathemainzel.info> wrote:
>On 01.01.2018 08:10, Robert Wessel wrote:
>> On Sun, 31 Dec 2017 23:46:26 -0500, Rod Pemberton
>> <EmailN...@nospicedham.voenflacbe.cpm> wrote:
>>
>>>
>>> x86 microcode paper
>>>
>>> Does anyone here follow USENIX or Hackaday.com?
>>>
>>> It came up on Hackaday that someone at USENIX this year hacked the x86
>>> microcode instructions. Their pdf report documents the microcode
>>> instruction set.
>>>
>>>
http://syssec.rub.de/research/publications/microcode-reversing/
>>>
>>>
>>> What I'm wondering is if more efficient code can be generated by C
>>> compilers if they "understand" the x86 micro-code?
>>
>>
>> Not really. Any instruction that's microcoded pretty much needs to be
>> avoided in any performance critical code.
>
>can you really say this?
>
>because: in a CPU generation the more expensive ones have less microcode
>the cheaper ones have more microcode, or is this wrong these days;
>
>this was knowledge in the 1990s and I guess this hasn't really changed;
Certainly smaller and less expensive CPUs tend to punt more special
cases and complex instructions to slow execution paths. For example
consider the handling of denormals in FP: they *can* be handled at
approximately full speed with some hardware overhead, but many smaller
processers with FP hardware handle them much more slowly than normal
numbers. Some processors implement longer versions of the vector
instructions as multiple shorter operations.
But this isn't the 60s, 70s or 80s, or event the 90s anymore. For the
most part "fast" CPUs are more likely to have more OoO resources,
cache, copies of execution units, etc., but not so much differences in
the actual execution of most instructions. A Silvermont and Skylake
can both do a single register to register add in a cycle, but the
Skylake can do more at once, but microcode is involved in neither.
But that doesn't matter. If you want fast performance on a processor,
avoid the places where that processor is slow, and almost everything
that invokes actual microcode on modern processors is slow. IOW, fast
code on an Intel Silvermont will be different than on a Skylake.
>> Of course if AMD or Intel fix a bug, an instruction may go from
>> hardwired to microcoded, and then take a considerable performance hit.
>
>is this true for the expensive CPUs of a generation?
>
>because this could kill any speed benefits of the more expensive CPUs ...
Well, sure. The point of the patch is to fix a bug. Doesn't matter
if the bug is in a Silvermont or a Skylake. In fact the smaller
processor might well have a (slightly) better chance of seeing a
minimal performance hit since more still will be microcoded anyway,
which means that you have some chance of hitting a bug in the
microcode part, which will presumably not be as badly impacted as
going from straight hardware execution to a microcode fix.
And the bugs can be subtle (consider the Meltdown and Spectre stuff),
and the fixes still painful (and partial).