aco: copy abs/neg with assignment
authorGeorg Lehmann <dadschoorse@gmail.com>
Tue, 7 Mar 2023 12:53:07 +0000 (13:53 +0100)
committerMarge Bot <emma+marge@anholt.net>
Thu, 9 Mar 2023 14:15:13 +0000 (14:15 +0000)
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21766>

src/amd/compiler/aco_ir.cpp
src/amd/compiler/aco_optimizer.cpp
src/amd/compiler/aco_ssa_elimination.cpp

index 4ce91fa..9e0c224 100644 (file)
@@ -304,8 +304,8 @@ convert_to_SDWA(amd_gfx_level gfx_level, aco_ptr<Instruction>& instr)
 
    if (tmp->isVOP3()) {
       VALU_instruction& vop3 = tmp->valu();
-      std::copy(std::cbegin(vop3.neg), std::cend(vop3.neg), std::begin(sdwa.neg));
-      std::copy(std::cbegin(vop3.abs), std::cend(vop3.abs), std::begin(sdwa.abs));
+      sdwa.neg = vop3.neg;
+      sdwa.abs = vop3.neg;
       sdwa.omod = vop3.omod;
       sdwa.clamp = vop3.clamp;
    }
@@ -406,8 +406,8 @@ convert_to_DPP(aco_ptr<Instruction>& instr, bool dpp8)
 
       if (tmp->isVOP3()) {
          const VALU_instruction* vop3 = &tmp->valu();
-         std::copy(std::cbegin(vop3->neg), std::cend(vop3->neg), std::begin(dpp->neg));
-         std::copy(std::cbegin(vop3->abs), std::cend(vop3->abs), std::begin(dpp->abs));
+         dpp->neg = vop3->neg;
+         dpp->abs = vop3->abs;
       }
    }
 
index 745eb1a..e5c5681 100644 (file)
@@ -1894,8 +1894,7 @@ label_instruction(opt_ctx& ctx, aco_ptr<Instruction>& instr)
    case aco_opcode::v_med3_f16:
    case aco_opcode::v_med3_f32: { /* clamp */
       VALU_instruction& vop3 = instr->valu();
-      if (vop3.abs[0] || vop3.abs[1] || vop3.abs[2] || vop3.neg[0] || vop3.neg[1] || vop3.neg[2] ||
-          vop3.omod != 0 || vop3.opsel != 0)
+      if (vop3.abs != 0 || vop3.neg != 0 || vop3.omod != 0 || vop3.opsel != 0)
          break;
 
       unsigned idx = 0;
@@ -2343,8 +2342,8 @@ combine_comparison_ordering(opt_ctx& ctx, aco_ptr<Instruction>& instr)
       VALU_instruction* new_vop3 =
          create_instruction<VALU_instruction>(new_op, asVOP3(Format::VOPC), 2, 1);
       VALU_instruction& cmp_vop3 = cmp->valu();
-      std::copy(std::cbegin(cmp_vop3.neg), std::cend(cmp_vop3.neg), std::begin(new_vop3->neg));
-      std::copy(std::cbegin(cmp_vop3.abs), std::cend(cmp_vop3.abs), std::begin(new_vop3->abs));
+      new_vop3->neg = cmp_vop3.neg;
+      new_vop3->abs = cmp_vop3.abs;
       new_vop3->clamp = cmp_vop3.clamp;
       new_vop3->omod = cmp_vop3.omod;
       new_vop3->opsel = cmp_vop3.opsel;
@@ -2544,8 +2543,8 @@ combine_constant_comparison_ordering(opt_ctx& ctx, aco_ptr<Instruction>& instr)
       VALU_instruction* new_vop3 =
          create_instruction<VALU_instruction>(new_op, asVOP3(Format::VOPC), 2, 1);
       VALU_instruction& cmp_vop3 = cmp->valu();
-      std::copy(std::cbegin(cmp_vop3.neg), std::cend(cmp_vop3.neg), std::begin(new_vop3->neg));
-      std::copy(std::cbegin(cmp_vop3.abs), std::cend(cmp_vop3.abs), std::begin(new_vop3->abs));
+      new_vop3->neg = cmp_vop3.neg;
+      new_vop3->abs = cmp_vop3.abs;
       new_vop3->clamp = cmp_vop3.clamp;
       new_vop3->omod = cmp_vop3.omod;
       new_vop3->opsel = cmp_vop3.opsel;
index 3ec17f8..c90c29b 100644 (file)
@@ -459,13 +459,6 @@ try_optimize_branching_sequence(ssa_elimination_ctx& ctx, Block& block, const in
          if (exec_val->isSDWA()) {
             /* This might work but it needs testing and more code to copy the instruction. */
             return;
-         } else if (!exec_val->isVOP3()) {
-            aco_ptr<Instruction> tmp = std::move(exec_val);
-            exec_val.reset(create_instruction<VALU_instruction>(
-               tmp->opcode, tmp->format, tmp->operands.size(), tmp->definitions.size() + 1));
-            std::copy(tmp->operands.cbegin(), tmp->operands.cend(), exec_val->operands.begin());
-            std::copy(tmp->definitions.cbegin(), tmp->definitions.cend(),
-                      exec_val->definitions.begin());
          } else {
             aco_ptr<Instruction> tmp = std::move(exec_val);
             exec_val.reset(create_instruction<VALU_instruction>(
@@ -479,8 +472,8 @@ try_optimize_branching_sequence(ssa_elimination_ctx& ctx, Block& block, const in
             dst.opsel = src.opsel;
             dst.omod = src.omod;
             dst.clamp = src.clamp;
-            std::copy(std::cbegin(src.abs), std::cend(src.abs), std::begin(dst.abs));
-            std::copy(std::cbegin(src.neg), std::cend(src.neg), std::begin(dst.neg));
+            dst.neg = src.neg;
+            dst.abs = src.abs;
          }
       }