Live data from Hacker News

I got nerd sniped into benchmarking legacy x86 instructions (2019)

acepace.net

21–30 of 47 posts

Re: I got nerd sniped into benchmarking legacy x86 instructions (2019)

#21
post #19

>>nerd sniped I honestly don't know anything about this stuff, but the title is awesome.

I never heard the term until I did it to someone. He said I nerd sniped him, but now there is an algebraic constraint solver written in Rust on github. He wrote a decent blog about it too.

Re: I got nerd sniped into benchmarking legacy x86 instructions (2019)

#23
post #8
post #3

> The meme is wrong The third panel is generally meant to be the correct technical answer, while the last panel is reserved for the punchline. Understanding the 'galaxy brain' format might have saved the author the trouble (or at least guided proper expectations), although it was a cool exercise.

I always thought of the last panel as an initially silly-sounding answer that could still be considered correct in some unexpected way. In this case it fits, because if you compile with `-Os`, xlatb is probably the ideal output. I doubt llvm can output xlatb, but I'd be pleasantly surprised if it could

If this meme was posted to pouet or another demoscene site in the context of writing 4k (or other) space constrained demos, it would operate as you expected.

If space efficiency (or fitting in cache) are important, then this instruction being more compact but having worse execution performance could be a good tradeoff!

Re: I got nerd sniped into benchmarking legacy x86 instructions (2019)

#24
post #17

Would someone mind explaining what all the assembly instructions in the meme do? In particular I'm wondering why you would do xor rcx, rcx when that result is always 0

We call those runes “the shibboleth of an assembly programmer.” They are ancient and wise. If one speaks them, one knows of and yearns for a simpler time when MOV vs XOR was a debate.

(Neighbor’s got it, and I am as unsure of contemporary relevance as they are.)

Re: I got nerd sniped into benchmarking legacy x86 instructions (2019)

#25
Hmm, uiCA results: xlatb: https://bit.ly/3cyBNN5 sequence: https://bit.ly/3nCmVTX

xlatb is looking better here. There are also some front end concerns that may favor xlatb, in particular if it's friendlier to the decoder. xlat is also fewer muops, taking less of the muop cache once decoded.

Re: I got nerd sniped into benchmarking legacy x86 instructions (2019)

#26
post #3

> The meme is wrong The third panel is generally meant to be the correct technical answer, while the last panel is reserved for the punchline. Understanding the 'galaxy brain' format might have saved the author the trouble (or at least guided proper expectations), although it was a cool exercise.

lol, no. Galaxy brain starts somewhere (generally sane and reasonable) and then moves progressively in a certain direction (generally more complicated). In this case the starting point is an instruction sequence that is reminiscent of RISC architectures and then it gets progressively more CISC as you go down the page. The whole point of galaxy brain is that it follows this sequence, and because there’s no special third panel the sequence is extensible to arbitrary lengths.

Re: I got nerd sniped into benchmarking legacy x86 instructions (2019)

#27
post #17

Would someone mind explaining what all the assembly instructions in the meme do? In particular I'm wondering why you would do xor rcx, rcx when that result is always 0

> why you would do xor rcx, rcx when that result is always 0 It's an idiomatic way to populate a register with the value zero. Not sure if it's still true, but IIRC it took fewer cycles than the more obvious "load #0 into $rcx" instruction.

These days you also get the benefit that it’s four bytes shorter, since it doesn’t have to store an immediate:

  48 31 c9                xor    rcx,rcx
  48 c7 c1 00 00 00 00    mov    rcx,0x0
(This is even shorter:

  31 c9                   xor    ecx,ecx
)

Re: I got nerd sniped into benchmarking legacy x86 instructions (2019)

#29
> what are the chances this obscure opcode is faster than optimized loads?

Sometimes it's not about being faster, sometimes it's about taking up less space. The graphic doesn't say what it's aiming for, and based on what I see in the graphic, the 4th panel seems to take up the least space.

Post reply on HN