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. Cc: Connor Abbott <cwabbo...@gmail.com> Cc: Timothy Arceri <tarc...@itsqueeze.com> Cc: Eric Anholt <e...@anholt.net> Cc: Rob Clark <robdcl...@gmail.com> Cc: Karol Herbst <karolher...@gmail.com> Cc: Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl> Jason Ekstrand (28): nir/opcodes: Pull in the type helpers from constant_expressions nir/opcodes: Rename tbool to tbool32 nir/algebraic: Clean up some __str__ cruft nir/algebraic: Refactor codegen a bit nir/algebraic: Add support for unsized conversion opcodes nir/opt_algebraic: Simplify an optimization using the new search ops nir/opt_algebraic: Drop bit-size suffixes from conversions nir/opt_algebraic: Add 32-bit specifiers to a bunch of booleans nir: Make boolean conversions sized just like the others nir/algebraic: Optimize x2b(xneg(a)) -> a nir: Drop support for lower_b2f nir/algebraic: Make an optimization more specific nir: Rename Boolean-related opcodes to include 32 in the name FIXUP: nir/builder: Generate 32-bit bool opcodes transparently FIXUP: nir/algebraic: Remap Boolean opcodes to the 32-bit variant FIXUP: Use 32-bit opcodes in the NIR producers and optimizations FIXUP: Use 32-bit opcodes in the NIR back-ends nir/constant_expressions: Rework Boolean handling nir: Add support for 1-bit data types nir/large_constants: Properly handle 1-bit bools nir/algebraic: Generalize an optimization nir: Add 1-bit Boolean opcodes nir: Add a bool to int32 lowering pass glsl,spirv: Generate 1-bit Booleans FIXUP: Revert "Use 32-bit opcodes in the NIR producers and optimizations" FIXUP: Revert "nir/builder: Generate 32-bit bool opcodes transparently" FIXUP: nir/builder: Generate 1-bit Booleans in nir_build_imm_bool nir/algebraic: Optimize 1-bit Booleans nir/algebraic: Add some optimizations for D3D-style Booleans src/amd/common/ac_nir_to_llvm.c | 34 +-- src/amd/vulkan/radv_shader.c | 2 + src/broadcom/compiler/nir_to_vir.c | 52 ++--- src/broadcom/compiler/vir.c | 2 + src/compiler/Makefile.sources | 1 + src/compiler/glsl/glsl_to_nir.cpp | 17 +- src/compiler/nir/meson.build | 1 + src/compiler/nir/nir.c | 15 +- src/compiler/nir/nir.h | 31 +-- src/compiler/nir/nir_algebraic.py | 84 ++++++-- src/compiler/nir/nir_builder.h | 28 ++- src/compiler/nir/nir_constant_expressions.py | 74 +++---- src/compiler/nir/nir_instr_set.c | 23 +- src/compiler/nir/nir_lower_alu_to_scalar.c | 4 + src/compiler/nir/nir_lower_bool_to_int32.c | 160 ++++++++++++++ src/compiler/nir/nir_lower_idiv.c | 2 +- src/compiler/nir/nir_lower_int64.c | 2 +- .../nir/nir_lower_load_const_to_scalar.c | 3 + src/compiler/nir/nir_opcodes.py | 98 ++++++--- src/compiler/nir/nir_opcodes_c.py | 41 ++-- src/compiler/nir/nir_opt_algebraic.py | 215 +++++++++--------- src/compiler/nir/nir_opt_constant_folding.c | 3 + src/compiler/nir/nir_opt_if.c | 2 +- src/compiler/nir/nir_opt_large_constants.c | 14 +- src/compiler/nir/nir_print.c | 3 + src/compiler/nir/nir_search.c | 114 +++++++++- src/compiler/nir/nir_search.h | 17 +- src/compiler/nir/nir_validate.c | 2 +- src/compiler/nir_types.cpp | 2 +- src/compiler/nir_types.h | 4 +- src/compiler/spirv/spirv_to_nir.c | 11 +- src/compiler/spirv/vtn_glsl450.c | 4 +- src/freedreno/ir3/ir3_compiler_nir.c | 34 +-- src/gallium/auxiliary/nir/tgsi_to_nir.c | 20 +- src/gallium/drivers/radeonsi/si_shader_nir.c | 2 + src/gallium/drivers/vc4/vc4_program.c | 50 ++--- src/intel/compiler/brw_fs_nir.cpp | 85 ++++---- src/intel/compiler/brw_nir.c | 2 + .../brw_nir_analyze_boolean_resolves.c | 24 +-- src/intel/compiler/brw_vec4_nir.cpp | 123 +++++------ src/mesa/program/prog_to_nir.c | 4 +- 41 files changed, 927 insertions(+), 465 deletions(-) create mode 100644 src/compiler/nir/nir_lower_bool_to_int32.c -- 2.19.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev