From 51c67ad7cfc806df8b0e0ca866b62ab5ffb6fc84 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 23 Oct 2024 00:01:52 -0700 Subject: [PATCH] brw: Avoid regioning restrictions for u2u16/i2i16 narrowing conversions Cuts 0.83% of instructions on Alchemist in affected fossil-db shaders (nearly all of which are in parallel-rdp). Reviewed-by: Caio Oliveira Part-of: --- src/intel/compiler/brw_from_nir.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/intel/compiler/brw_from_nir.cpp b/src/intel/compiler/brw_from_nir.cpp index be666f63a6b..4954d9c1951 100644 --- a/src/intel/compiler/brw_from_nir.cpp +++ b/src/intel/compiler/brw_from_nir.cpp @@ -1124,6 +1124,16 @@ brw_from_nir_emit_alu(nir_to_brw_state &ntb, nir_alu_instr *instr, } } + /* If narrowing (e.g. 32 -> 16), don't do a D -> W or UD -> UW mov, + * instead just read the source as W/UW with a stride (discarding + * the top bits). This avoids the need for the destination to be + * DWord aligned due to regioning restrictions. + */ + if (brw_type_size_bits(result.type) < brw_type_size_bits(op[0].type)) { + const unsigned bits = brw_type_size_bits(result.type); + op[0] = subscript(op[0], brw_type_with_size(op[0].type, bits), 0); + } + bld.MOV(result, op[0]); break; }