aco: don't reorder instructions in order to lower boolean phis
authorDaniel Schürmann <daniel@schuermann.dev>
Mon, 7 Oct 2019 00:52:55 +0000 (02:52 +0200)
committerDaniel Schürmann <daniel@schuermann.dev>
Wed, 9 Oct 2019 15:50:23 +0000 (17:50 +0200)
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
src/amd/compiler/aco_lower_bool_phis.cpp

index 7a4940ab1c83e5c66aebe19503b7a6d17f7ff020..ac4663a2ce195f9e161e22428f05826247b255c8 100644 (file)
@@ -216,36 +216,18 @@ void lower_linear_bool_phi(Program *program, Block *block, aco_ptr<Instruction>&
 void lower_bool_phis(Program* program)
 {
    for (Block& block : program->blocks) {
-      std::vector<aco_ptr<Instruction>> instructions;
-      std::vector<aco_ptr<Instruction>> non_phi;
-      instructions.swap(block.instructions);
-      block.instructions.reserve(instructions.size());
-      unsigned i = 0;
-      for (; i < instructions.size(); i++)
-      {
-         aco_ptr<Instruction>& phi = instructions[i];
-         if (phi->opcode != aco_opcode::p_phi && phi->opcode != aco_opcode::p_linear_phi)
-            break;
-         if (phi->opcode == aco_opcode::p_phi && phi->definitions[0].regClass() == s2) {
-            lower_divergent_bool_phi(program, &block, phi);
-            block.instructions.emplace_back(std::move(phi));
-         } else if (phi->opcode == aco_opcode::p_linear_phi && phi->definitions[0].regClass() == s1) {
+      for (aco_ptr<Instruction>& phi : block.instructions) {
+         if (phi->opcode == aco_opcode::p_phi) {
+            if (phi->definitions[0].regClass() == s2)
+               lower_divergent_bool_phi(program, &block, phi);
+         } else if (phi->opcode == aco_opcode::p_linear_phi) {
             /* if it's a valid non-boolean phi, this should be a no-op */
-            lower_linear_bool_phi(program, &block, phi);
-            block.instructions.emplace_back(std::move(phi));
+            if (phi->definitions[0].regClass() == s1)
+               lower_linear_bool_phi(program, &block, phi);
          } else {
-            block.instructions.emplace_back(std::move(phi));
+            break;
          }
       }
-      for (auto&& instr : non_phi) {
-         assert(instr->opcode != aco_opcode::p_phi && instr->opcode != aco_opcode::p_linear_phi);
-         block.instructions.emplace_back(std::move(instr));
-      }
-      for (; i < instructions.size(); i++) {
-         aco_ptr<Instruction> instr = std::move(instructions[i]);
-         assert(instr->opcode != aco_opcode::p_phi && instr->opcode != aco_opcode::p_linear_phi);
-         block.instructions.emplace_back(std::move(instr));
-      }
    }
 }