freedreno/ir3: Move i/o offset lowering after analyze_ubo_ranges.
authorEric Anholt <eric@anholt.net>
Fri, 1 May 2020 23:00:17 +0000 (16:00 -0700)
committerMarge Bot <eric+marge@anholt.net>
Thu, 14 May 2020 00:10:43 +0000 (00:10 +0000)
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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4858>

src/freedreno/ir3/ir3_nir.c
src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c

index fe25f39d0e52b3b03aa899631d0c4743aaebd2cc..61a5153961ad31ec77b8cb430607c9fa76c43f0d 100644 (file)
@@ -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);
 
index d60c2c64d106644fd2b516ded88a6f25b79c4dac..eb252eb7c36e9fb49a9f1d01ff1e8b97462ae66e 100644 (file)
@@ -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