aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Schürmann <[email protected]>2019-10-07 02:52:55 +0200
committerDaniel Schürmann <[email protected]>2019-10-09 17:50:23 +0200
commitf584c427077bfacea9feef5846c92896e7101449 (patch)
tree4b52c3c1d18d59dfda502c2ea261f46ca4a958dd
parent10be90671f3d01ca0e7162fdc3ebadc2e6f6094c (diff)
aco: don't reorder instructions in order to lower boolean phis
Reviewed-by: Rhys Perry <[email protected]>
-rw-r--r--src/amd/compiler/aco_lower_bool_phis.cpp34
1 files changed, 8 insertions, 26 deletions
diff --git a/src/amd/compiler/aco_lower_bool_phis.cpp b/src/amd/compiler/aco_lower_bool_phis.cpp
index 7a4940ab1c8..ac4663a2ce1 100644
--- a/src/amd/compiler/aco_lower_bool_phis.cpp
+++ b/src/amd/compiler/aco_lower_bool_phis.cpp
@@ -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));
- }
}
}