From d5176c453e5fd74f6999d09e551bcbc771845e8f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 1 May 2020 16:00:17 -0700 Subject: [PATCH] freedreno/ir3: Move i/o offset lowering after analyze_ubo_ranges. I found that when moving more UBOs to load_ubo_ir3, analyze_ubo_ranges would move things back in a broken way. We can just run this pass later and drop the _ir3 path. Part-of: --- src/freedreno/ir3/ir3_nir.c | 4 +++- .../ir3/ir3_nir_analyze_ubo_ranges.c | 22 ++++++++----------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/freedreno/ir3/ir3_nir.c b/src/freedreno/ir3/ir3_nir.c index fe25f39d0e5..61a5153961a 100644 --- a/src/freedreno/ir3/ir3_nir.c +++ b/src/freedreno/ir3/ir3_nir.c @@ -274,7 +274,6 @@ ir3_optimize_nir(struct ir3_shader *shader, nir_shader *s, } OPT_V(s, nir_lower_regs_to_ssa); - OPT_V(s, ir3_nir_lower_io_offsets); if (key) { if (s->info.stage == MESA_SHADER_VERTEX) { @@ -317,6 +316,9 @@ ir3_optimize_nir(struct ir3_shader *shader, nir_shader *s, */ const bool ubo_progress = !key && OPT(s, ir3_nir_analyze_ubo_ranges, shader); const bool idiv_progress = OPT(s, nir_lower_idiv, nir_lower_idiv_fast); + /* UBO offset lowering has to come after we've decided what will be left as load_ubo */ + OPT_V(s, ir3_nir_lower_io_offsets); + if (ubo_progress || idiv_progress) ir3_optimize_loop(s); diff --git a/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c b/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c index d60c2c64d10..eb252eb7c36 100644 --- a/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c +++ b/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c @@ -33,8 +33,6 @@ get_ubo_load_range(nir_intrinsic_instr *instr) struct ir3_ubo_range r; int offset = nir_src_as_uint(instr->src[1]); - if (instr->intrinsic == nir_intrinsic_load_ubo_ir3) - offset *= 16; const int bytes = nir_intrinsic_dest_components(instr) * 4; r.start = ROUND_DOWN_TO(offset, 16 * 4); @@ -242,9 +240,8 @@ lower_ubo_load_to_uniform(nir_intrinsic_instr *instr, nir_builder *b, * offset is in units of 16 bytes, so we need to multiply by 4. And * also the same for the constant part of the offset: */ - - const int shift = instr->intrinsic == nir_intrinsic_load_ubo_ir3 ? 2 : -2; - nir_ssa_def *new_offset = ir3_nir_try_propagate_bit_shift(b, ubo_offset, shift); + const int shift = -2; + nir_ssa_def *new_offset = ir3_nir_try_propagate_bit_shift(b, ubo_offset, -2); nir_ssa_def *uniform_offset = NULL; if (new_offset) { uniform_offset = new_offset; @@ -254,13 +251,8 @@ lower_ubo_load_to_uniform(nir_intrinsic_instr *instr, nir_builder *b, nir_ushr(b, ubo_offset, nir_imm_int(b, -shift)); } - if (instr->intrinsic == nir_intrinsic_load_ubo_ir3) { - const_offset <<= 2; - const_offset += nir_intrinsic_base(instr); - } else { - debug_assert(!(const_offset & 0x3)); - const_offset >>= 2; - } + debug_assert(!(const_offset & 0x3)); + const_offset >>= 2; const int range_offset = ((int)range->offset - (int)range->start) / 4; const_offset += range_offset; @@ -300,7 +292,11 @@ instr_is_load_ubo(nir_instr *instr) return false; nir_intrinsic_op op = nir_instr_as_intrinsic(instr)->intrinsic; - return op == nir_intrinsic_load_ubo || op == nir_intrinsic_load_ubo_ir3; + + /* ir3_nir_lower_io_offsets happens after this pass. */ + assert(op != nir_intrinsic_load_ubo_ir3); + + return op == nir_intrinsic_load_ubo; } bool -- 2.30.2