Skip to content

aco: chain branches instead of emitting long jumps

I think the main benefit of this MR isn't the improved stats but the simplification of the compiler. It was quite annoying to have definitions at the branches because they interfered with the phis.

As regular branch instructions cannot jump further than
32768 dwords, previously we used long jumps as fallback
solution. The disadvantage of that is that an extra SGPR
pair must be provided in order to temporarily store the PC.

This patch changes that to chained branch instructions by
inserting an artificial extra block into the code to be
targeted by the original branch. This block contains a
single branch instruction jumping to the original target.
Before the block, if necessary, we insert a <branch 1>
instruction for the existing code in order to jump over
the newly inserted block.

total changes of this MR (Navi31):

Totals:
Instrs: 41413316 -> 41408908 (-0.01%); split: -0.04%, +0.03%
CodeSize: 218120440 -> 218090448 (-0.01%); split: -0.03%, +0.02%
SpillSGPRs: 6028 -> 6058 (+0.50%); split: -0.56%, +1.06%
Latency: 292771215 -> 292716817 (-0.02%); split: -0.02%, +0.00%
InvThroughput: 46064001 -> 46059166 (-0.01%); split: -0.01%, +0.00%
SClause: 1288929 -> 1288849 (-0.01%); split: -0.01%, +0.00%
Copies: 2545937 -> 2545804 (-0.01%); split: -0.02%, +0.02%
Branches: 797733 -> 797732 (-0.00%); split: -0.00%, +0.00%
PreSGPRs: 2422628 -> 2417824 (-0.20%)

Totals from 21668 (27.36% of 79206) affected shaders:
Instrs: 22157069 -> 22152661 (-0.02%); split: -0.08%, +0.06%
CodeSize: 118024568 -> 117994576 (-0.03%); split: -0.06%, +0.04%
SpillSGPRs: 4378 -> 4408 (+0.69%); split: -0.78%, +1.46%
Latency: 201633451 -> 201579053 (-0.03%); split: -0.03%, +0.00%
InvThroughput: 33938096 -> 33933261 (-0.01%); split: -0.02%, +0.00%
SClause: 709175 -> 709095 (-0.01%); split: -0.01%, +0.00%
Copies: 1453003 -> 1452870 (-0.01%); split: -0.04%, +0.03%
Branches: 510488 -> 510487 (-0.00%); split: -0.00%, +0.00%
PreSGPRs: 852190 -> 847386 (-0.56%)

Merge request reports

Loading