Re: RFC: Petition Intel/AMD to add POPF_IF insn

From: Denys Vlasenko
Date: Wed Aug 17 2016 - 15:36:12 EST




On 08/17/2016 09:32 PM, Linus Torvalds wrote:
On Wed, Aug 17, 2016 at 12:26 PM, Denys Vlasenko <dvlasenk@xxxxxxxxxx> wrote:

Exactly. And more:

All of which is ENTIRELY IRRELEVANT.

The 2-page pseudo-code is about behavior. It's trivial to
short-circuit. There are obvious optimizations, which involve just
making the rare cases go slow and have a trivial "if those bits didn't
change, don't go through the expense of testing them".

The problem is that IF is almost certainly right now in that rare case
mask, and so popf is stupidly slow for IF.

I ran the test, see the first email in the thread.

Experimentally, POPF is stupidly slow _always_. 6 cycles
even if none of the "scary" flags are changed.
Either:
* its microcode has no rare case mask
or
* its microcode is so slow that even fast path is slow,
and slow path is worse