aco: remove some unused optimizations
authorRhys Perry <pendingchaos02@gmail.com>
Thu, 15 Oct 2020 14:18:40 +0000 (15:18 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 27 Oct 2020 15:24:38 +0000 (15:24 +0000)
These are unused now that we almost always use p_parallelcopy for simple
copies.

No fossil-db changes.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7216>

src/amd/compiler/aco_opt_value_numbering.cpp
src/amd/compiler/aco_optimizer.cpp

index 12b376f..744bafd 100644 (file)
@@ -389,15 +389,10 @@ void process_block(vn_ctx& ctx, Block& block)
       }
 
       /* simple copy-propagation through renaming */
-      bool copy_instr =
-         instr->opcode == aco_opcode::s_mov_b32 ||
-         instr->opcode == aco_opcode::s_mov_b64 ||
-         instr->opcode == aco_opcode::v_mov_b32 ||
-         instr->opcode == aco_opcode::p_parallelcopy ||
-         (instr->opcode == aco_opcode::p_create_vector && instr->operands.size() == 1);
+      bool copy_instr = instr->opcode == aco_opcode::p_parallelcopy ||
+                        (instr->opcode == aco_opcode::p_create_vector && instr->operands.size() == 1);
       if (copy_instr && !instr->definitions[0].isFixed() && instr->operands[0].isTemp() &&
-          instr->operands[0].regClass() == instr->definitions[0].regClass() &&
-          !instr->isDPP() && !((int)instr->format & (int)Format::SDWA)) {
+          instr->operands[0].regClass() == instr->definitions[0].regClass()) {
          ctx.renames[instr->definitions[0].tempId()] = instr->operands[0].getTemp();
          continue;
       }
index 2d7f848..7c3cdfd 100644 (file)
@@ -814,6 +814,11 @@ void label_instruction(opt_ctx &ctx, Block& block, aco_ptr<Instruction>& instr)
       for (Operand& op : instr->operands)
          all_const = all_const && (!op.isTemp() || ctx.info[op.tempId()].is_constant_or_literal(32));
       perfwarn(ctx.program, all_const, "All instruction operands are constant", instr.get());
+
+      ASSERTED bool is_copy = instr->opcode == aco_opcode::s_mov_b32 ||
+                              instr->opcode == aco_opcode::s_mov_b64 ||
+                              instr->opcode == aco_opcode::v_mov_b32;
+      perfwarn(ctx.program, is_copy && !instr->usesModifiers(), "Use p_parallelcopy instead", instr.get());
    }
 
    for (unsigned i = 0; i < instr->operands.size(); i++)
@@ -1210,10 +1215,7 @@ void label_instruction(opt_ctx &ctx, Block& block, aco_ptr<Instruction>& instr)
       }
       break;
    }
-   case aco_opcode::s_mov_b32: /* propagate */
-   case aco_opcode::s_mov_b64:
-   case aco_opcode::v_mov_b32:
-   case aco_opcode::p_parallelcopy:
+   case aco_opcode::p_parallelcopy: /* propagate */
       if (instr->operands[0].isTemp() && ctx.info[instr->operands[0].tempId()].is_vec() &&
           instr->operands[0].regClass() != instr->definitions[0].regClass()) {
          /* We might not be able to copy-propagate if it's a SGPR->VGPR copy, so
@@ -1252,29 +1254,6 @@ void label_instruction(opt_ctx &ctx, Block& block, aco_ptr<Instruction>& instr)
       if (!ctx.program->needs_wqm)
          ctx.info[instr->definitions[0].tempId()].set_constant(ctx.program->chip_class, 0u);
       break;
-   case aco_opcode::s_movk_i32: {
-      uint32_t v = static_cast<SOPK_instruction*>(instr.get())->imm;
-      v = v & 0x8000 ? (v | 0xffff0000) : v;
-      ctx.info[instr->definitions[0].tempId()].set_constant(ctx.program->chip_class, v);
-      break;
-   }
-   case aco_opcode::v_bfrev_b32:
-   case aco_opcode::s_brev_b32: {
-      if (instr->operands[0].isConstant()) {
-         uint32_t v = util_bitreverse(instr->operands[0].constantValue());
-         ctx.info[instr->definitions[0].tempId()].set_constant(ctx.program->chip_class, v);
-      }
-      break;
-   }
-   case aco_opcode::s_bfm_b32: {
-      if (instr->operands[0].isConstant() && instr->operands[1].isConstant()) {
-         unsigned size = instr->operands[0].constantValue() & 0x1f;
-         unsigned start = instr->operands[1].constantValue() & 0x1f;
-         uint32_t v = ((1u << size) - 1u) << start;
-         ctx.info[instr->definitions[0].tempId()].set_constant(ctx.program->chip_class, v);
-      }
-      break;
-   }
    case aco_opcode::v_mul_f16:
    case aco_opcode::v_mul_f32: { /* omod */
       ctx.info[instr->definitions[0].tempId()].set_mul(instr.get());