freedreno/ir3: remove unused tex arg harder
authorRob Clark <robdclark@chromium.org>
Fri, 24 Jan 2020 00:45:29 +0000 (16:45 -0800)
committerMarge Bot <eric+marge@anholt.net>
Sat, 1 Feb 2020 02:40:22 +0000 (02:40 +0000)
Just killing the SSA link isn't enough.  It confuses RA, legalize,
and postsched to see a bogus unused reg.

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

src/freedreno/ir3/ir3.c
src/freedreno/ir3/ir3_cp.c
src/freedreno/ir3/ir3_print.c

index b9bcf3b08bdbd3660009a9c0c893c8426ec72409..f8cfc6bb3c0eba8c39e3ea7a750761bfc326dcca 100644 (file)
@@ -463,23 +463,15 @@ static int emit_cat5(struct ir3_instruction *instr, void *ptr,
        instr_cat5_t *cat5 = ptr;
 
        iassert((instr->regs_count == 2) ||
-                       (instr->regs_count == 3) || (instr->regs_count == 4));
+                       (instr->regs_count == 3) ||
+                       (instr->regs_count == 4));
 
-       switch (instr->opc) {
-       case OPC_DSX:
-       case OPC_DSXPP_1:
-       case OPC_DSY:
-       case OPC_DSYPP_1:
-       case OPC_RGETPOS:
-       case OPC_RGETINFO:
-               iassert((instr->flags & IR3_INSTR_S2EN) == 0);
-               src1 = instr->regs[1];
-               src2 = instr->regs_count > 2 ? instr->regs[2] : NULL;
-               break;
-       default:
+       if (instr->flags & IR3_INSTR_S2EN) {
                src1 = instr->regs[2];
                src2 = instr->regs_count > 3 ? instr->regs[3] : NULL;
-               break;
+       } else {
+               src1 = instr->regs[1];
+               src2 = instr->regs_count > 2 ? instr->regs[2] : NULL;
        }
 
        assume(src1 || !src2);
index e04f1daae6b8a6cc17e1665958e5ac9d7efcf0a8..28c9f82f3ae3ee90f7216d5b57cca4cd2cdb32b4 100644 (file)
@@ -723,7 +723,12 @@ instr_cp(struct ir3_cp_ctx *ctx, struct ir3_instruction *instr)
                        instr->flags &= ~IR3_INSTR_S2EN;
                        instr->cat5.samp = samp->regs[1]->iim_val;
                        instr->cat5.tex  = tex->regs[1]->iim_val;
-                       instr->regs[1]->instr = NULL;
+
+                       /* shuffle around the regs to remove the first src: */
+                       instr->regs_count--;
+                       for (unsigned i = 1; i < instr->regs_count; i++) {
+                               instr->regs[i] = instr->regs[i + 1];
+                       }
                }
        }
 }
index 244239dd24096a76555a5cd01e1520593e7f6fa6..381319311a334f040723a23e8faf69a7264b9c55 100644 (file)
@@ -206,10 +206,6 @@ print_instr(struct ir3_instruction *instr, int lvl)
        for (i = 0; i < instr->regs_count; i++) {
                struct ir3_register *reg = instr->regs[i];
 
-               /* skip the samp/tex src if it has been lowered to immed: */
-               if ((i == 1) && is_tex(instr) && !(instr->flags & IR3_INSTR_S2EN))
-                       continue;
-
                printf(i ? ", " : "");
                print_reg_name(reg);
        }