mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 20:00:10 +01:00
aco: Cleanup insert_before_logical_end
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
This commit is contained in:
parent
c8554f849e
commit
a607ea51a7
1 changed files with 11 additions and 15 deletions
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include "aco_ir.h"
|
#include "aco_ir.h"
|
||||||
#include "aco_builder.h"
|
#include "aco_builder.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
namespace aco {
|
namespace aco {
|
||||||
|
|
@ -120,24 +121,19 @@ Temp write_ssa(Program *program, Block *block, ssa_state *state, unsigned previo
|
||||||
return {id, s2};
|
return {id, s2};
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert_before_branch(Block *block, aco_ptr<Instruction> instr)
|
|
||||||
{
|
|
||||||
int end = block->instructions.size() - 1;
|
|
||||||
if (block->instructions[end]->format == Format::PSEUDO_BRANCH)
|
|
||||||
block->instructions.emplace(std::prev(block->instructions.end()), std::move(instr));
|
|
||||||
else
|
|
||||||
block->instructions.emplace_back(std::move(instr));
|
|
||||||
}
|
|
||||||
|
|
||||||
void insert_before_logical_end(Block *block, aco_ptr<Instruction> instr)
|
void insert_before_logical_end(Block *block, aco_ptr<Instruction> instr)
|
||||||
{
|
{
|
||||||
for (int i = block->instructions.size() - 1; i >= 0; --i) {
|
auto IsLogicalEnd = [] (const aco_ptr<Instruction>& instr) -> bool {
|
||||||
if (block->instructions[i]->opcode == aco_opcode::p_logical_end) {
|
return instr->opcode == aco_opcode::p_logical_end;
|
||||||
block->instructions.emplace(std::next(block->instructions.begin(), i), std::move(instr));
|
};
|
||||||
return;
|
auto it = std::find_if(block->instructions.crbegin(), block->instructions.crend(), IsLogicalEnd);
|
||||||
}
|
|
||||||
|
if (it == block->instructions.crend()) {
|
||||||
|
assert(block->instructions.back()->format == Format::PSEUDO_BRANCH);
|
||||||
|
block->instructions.insert(std::prev(block->instructions.end()), std::move(instr));
|
||||||
}
|
}
|
||||||
insert_before_branch(block, std::move(instr));
|
else
|
||||||
|
block->instructions.insert(std::prev(it.base()), std::move(instr));
|
||||||
}
|
}
|
||||||
|
|
||||||
aco_ptr<Instruction> lower_divergent_bool_phi(Program *program, Block *block, aco_ptr<Instruction>& phi)
|
aco_ptr<Instruction> lower_divergent_bool_phi(Program *program, Block *block, aco_ptr<Instruction>& phi)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue