Skip to content

nir: Use a 1-bit data type for booleans

Faith Ekstrand requested to merge gfxstrand/mesa:review/nir-1-bit-bool into master

This is a v2 of my series to switch NIR over to 1-bit Booleans. The first version of the series can be found here:

https://patchwork.freedesktop.org/series/51351/

Since then, a bit of work has been done on NIR to make the transition a bit smoother. Connor rewrote the entire bit-size inference infrastructure in nir_algebraic.py to be more dynamic and accurate. On top of that, I reworked x2b conversions to work like other conversions and have a sized destination instead of having a fixed size on the source and unsized destination. This means that switching to 1-bit booleans doesn't involve those weird b322x opcodes that were in the first version. A few of the patches from the first version have also landed in the intervening time.

Shader-db results on Kaby Lake for the entire series:

total instructions in shared programs: 15072525 -> 14977978 (-0.63%)
instructions in affected programs: 1178699 -> 1084152 (-8.02%)
helped: 2126
HURT: 14

total cycles in shared programs: 369737290 -> 359790175 (-2.69%)
cycles in affected programs: 127174789 -> 117227674 (-7.82%)
helped: 2020
HURT: 325

total loops in shared programs: 4401 -> 4401 (0.00%)
loops in affected programs: 0 -> 0
helped: 0
HURT: 0

total spills in shared programs: 10158 -> 10051 (-1.05%)
spills in affected programs: 1429 -> 1322 (-7.49%)
helped: 8
HURT: 15

total fills in shared programs: 22105 -> 21732 (-1.69%)
fills in affected programs: 2532 -> 2159 (-14.73%)
helped: 9
HURT: 15

I've tried, by adding a lowering pass and enabling it, to ensure that this series doesn't break anyone's drivers. However, as with any other core NIR rework, please test. I don't have the capability to really test anything other than Intel.

Merge request reports

Loading