Skip to content

nir: refactor nir_opt_move

Daniel Schürmann requested to merge daniel-schuermann/mesa:nir_opt_move into main

This patch is a rewrite of nir_opt_move. Differently from the previous version, each instruction is checked if it can be moved downwards and then inserted before the first user of the definition. The advantage is that less insert operations are performed, the original order is kept if two movable instructions have the same first user, and instructions without user in the same block are moved towards the end.

v2: Only return true if an instruction really changed the position. Don't care for discards, this will be handled by another MR.

Changing the iteration order for ALU instructions in the old version has a similar effect.

Polaris:
69466 shaders in 34903 tests
Totals:
SGPRS: 3159562 -> 3158109 (-0.05 %)
VGPRS: 2303416 -> 2302280 (-0.05 %)
Spilled SGPRs: 748 -> 748 (0.00 %)
Spilled VGPRs: 0 -> 0 (0.00 %)
Private memory VGPRs: 0 -> 0 (0.00 %)
Scratch size: 252 -> 252 (0.00 %) dwords per thread
Code Size: 121693092 -> 121620568 (-0.06 %) bytes
LDS: 1080 -> 1080 (0.00 %) blocks
Max Waves: 466469 -> 466557 (0.02 %)

Totals from affected shaders:
SGPRS: 896651 -> 895198 (-0.16 %)
VGPRS: 754252 -> 753116 (-0.15 %)
Spilled SGPRs: 295 -> 295 (0.00 %)
Spilled VGPRs: 0 -> 0 (0.00 %)
Private memory VGPRs: 0 -> 0 (0.00 %)
Scratch size: 0 -> 0 (0.00 %) dwords per thread
Code Size: 51645908 -> 51573384 (-0.14 %) bytes
LDS: 147 -> 147 (0.00 %) blocks
Max Waves: 102436 -> 102524 (0.09 %)
Edited by Jordan Justen

Merge request reports