freedreno/ir3: be iterative
authorRob Clark <robdclark@chromium.org>
Thu, 14 May 2020 19:09:35 +0000 (12:09 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 19 May 2020 16:06:17 +0000 (16:06 +0000)
It does pick up a few more cf/cp opportunities, according to sharder-db.
But don't think it will be measurable.

But this will allow some future simplification to cp by pulling out it's
internal iteration.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5048>

src/freedreno/ir3/ir3_cf.c
src/freedreno/ir3/ir3_compiler_nir.c

index 89f2a8f52ac4956b9089c46230fdd171d9f7d4d8..2b35bc5e4730f360f9a36f0ed6acccbc4b224ef1 100644 (file)
@@ -85,7 +85,11 @@ try_conversion_folding(struct ir3_instruction *conv)
        if (!is_fp16_conv(conv))
                return false;
 
+       /* NOTE: we can have non-ssa srcs after copy propagation: */
        src = ssa(conv->regs[1]);
+       if (!src)
+               return false;
+
        if (!is_alu(src))
                return false;
 
index 4a55f578c4500bd9860fd0bb751a937ec3b62725..e6a179dc40c6ecd854362c5c485445f3a7a1294c 100644 (file)
@@ -3426,6 +3426,7 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler,
        struct ir3_context *ctx;
        struct ir3 *ir;
        int ret = 0, max_bary;
+       bool progress;
 
        assert(!so->ir);
 
@@ -3554,16 +3555,24 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler,
 
        ir3_debug_print(ir, "AFTER: nir->ir3");
 
-       IR3_PASS(ir, ir3_cf);
-       IR3_PASS(ir, ir3_cp, so);
+       do {
+               progress = false;
+
+               progress |= IR3_PASS(ir, ir3_cf);
+               progress |= IR3_PASS(ir, ir3_cp, so);
+               progress |= IR3_PASS(ir, ir3_dce, so);
+       } while (progress);
 
        /* at this point, for binning pass, throw away unneeded outputs:
         * Note that for a6xx and later, we do this after ir3_cp to ensure
         * that the uniform/constant layout for BS and VS matches, so that
         * we can re-use same VS_CONST state group.
         */
-       if (so->binning_pass && (ctx->compiler->gpu_id >= 600))
+       if (so->binning_pass && (ctx->compiler->gpu_id >= 600)) {
                fixup_binning_pass(ctx);
+               /* cleanup the result of removing unneeded outputs: */
+               while (IR3_PASS(ir, ir3_dce, so)) {}
+       }
 
        IR3_PASS(ir, ir3_sched_add_deps);
 
@@ -3572,7 +3581,8 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler,
         */
        IR3_PASS(ir, ir3_group);
 
-       IR3_PASS(ir, ir3_dce, so);
+       /* At this point, all the dead code should be long gone: */
+       assert(!IR3_PASS(ir, ir3_dce, so));
 
        ret = ir3_sched(ir);
        if (ret) {