freedreno/a2xx: ir2: fix incorrect instruction reordering
authorJonathan Marek <jonathan@marek.ca>
Thu, 5 Sep 2019 15:23:53 +0000 (11:23 -0400)
committerJonathan Marek <jonathan@marek.ca>
Fri, 6 Sep 2019 02:24:29 +0000 (02:24 +0000)
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Rob Clark <robdclark@chromium.org>
src/gallium/drivers/freedreno/a2xx/ir2.c

index 8995d7e8aaf90b9e0453e9a01ea9c077187ff097..89ac21a81e1aed27b3ec07063c7811e67bc835ce 100644 (file)
@@ -258,6 +258,22 @@ static int sched_next(struct ir2_context *ctx, struct ir2_sched_instr *sched)
                                is_ok &= !ctx->instr[src->num].need_emit;
                        }
                }
+               /* don't reorder non-ssa write before read */
+               if (!instr->is_ssa) {
+                       ir2_foreach_instr(p, ctx) {
+                               if (!p->need_emit || p->idx >= instr->idx)
+                                       continue;
+
+                               ir2_foreach_src(src, p) {
+                                       if (get_reg_src(ctx, src) == instr->reg)
+                                               is_ok = false;
+                               }
+                       }
+               }
+               /* don't reorder across predicates */
+               if (avail_count && instr->pred != avail[0]->pred)
+                       is_ok = false;
+
                if (!is_ok)
                        continue;