logoalt Hacker News

The Case of the Missing Increment

68 pointsby eigenform09/27/202421 commentsview on HN

Comments

zokier10/01/2024

> Since the only Alder Lake machine I had access to was a remote Windows machine that didn’t belong to me, I more-or-less had to choose option 3, which meant subjecting myself to The Ultimate Sadness

Well, you can pick up Sapphire Rapids instances from your preferred cloud provider and avoid the sadness.

show 1 reply
Taniwha10/01/2024

Thinking about this - this may be a pattern that;s designed to match something that expands from a string instruction.

While the loop he's testing is a useless bit of code that does nothing the optimisation he's discovered may help speed things like scasb/stosb allowing portions of 2 unrolled copies to be processed per clock

pkhuong10/01/2024

I believe I first saw this on IACA; uops.info has the measurements for zero-latency inc, add, etc on Alder Lake https://uops.info/html-instr/INC_R64.html . These adds by immediate are nicely closed, so I've been assuming renamed values are uniformly represented in Golden Cove as register+increment.

mzs10/01/2024

You have to use an instruction like cpuid with rdtsc so that the TSC is not read before the loop terminates. There have been changes to the Intel docs and there are more options now:

https://stackoverflow.com/a/58146426

Also in the bad old days SMM would interfere on some CPUs.

leiroigh10/01/2024

That's pretty cool.

Normally it would be the either the programmer's or the compiler's job to unroll a loop and then reduce dependency chain lengths.

But its nice if the renamer can do that as well.

Presumably intel have real-world data that suggest that significant real workloads can profit from this.

I wonder whether that points to specific software issues, like hypothetically "oh yeah, openjdk8 hotspot was a little too timid at loop unrolling. It won't get that JIT improvement backported, but our customers will use java8 forever. Better fix that in silicon".

buttocks10/01/2024

Deep thoughts: why aren’t “increment” and “excrement” opposites?

show 2 replies
vardump10/01/2024

Just when you get used with features like x86 CPUs combining two instructions into one micro-op (micro-op fusing), you get something like this.

I guess immediate addressing mode addition is a good choice to execute at rename / allocation stage, as it's common, relatively simple and can't generate exceptions.

show 2 replies