• As part of the relaunch of Skullheart, ALL previous threads have been archived. You can find them at the bottom of the forum in the Archives (2021) section. The archives are locked, so please use the new forum sections to create new discussion threads.

Are these ancient optimizations still relevant?

Status
Not open for further replies.

Scott53

New Member
Joined
Sep 7, 2021
Messages
1
Reaction score
0
Points
1
Steam
Scott
Eliza Beowulf
I'm in the process of writing a software renderer raycaster. I've actually done this before a very long time ago on a 386. Back in the day, in order to get a good frame rate, I had to incorporate several programming tricks, and I'm wondering if they are still relevant. Even if they are, do modern compilers simply do it for me, and what about inline assembly, does that also get reordered?

  1. Alternating 32 and 16 bit instructions. The 386 introduced 32 bit register, but maintained backwards compatibility by having the lower half act as 16 bit registers. For multi clock cycle instructions, the CPU could overlap them, so you'd write code to go something like ADD EAX EBX, SUB CX DX…
  2. Alternating int and float math. Most machines at the time did floating point math in a coprocessor, which ran in parallel with the main CPU. By alternating 2 int, 1 float, 2 int, 1 float, you'd get essentially parallel processing.
  3. Jumping on less likely branch. The compiler I used would turn if(…)then(x)else(y) into cmp,jne,x… So you'd always make the most likely code to run away for the else
With the improvements of branch prediction and pipelining in the last several generations of chips, are any of these still relevant?
 
@Scott53, this was posted in the Skullgirls gameplay section, but I'm unsure what this has to do with Skullgirls. I don't think this kind of conversation really belongs on Skullheart, you may want to try your luck on Reddit or a tech Discord?
 
Status
Not open for further replies.