mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 17:40:11 +01:00
aco: Remove branch instruction when exec is constant non-zero.
This mainly helps the "if (elect())" that is used in NGG culling shaders, effectively removing a useless branch from every culling shader. Totals from 58346 (45.35% of 128653) affected shaders: CodeSize: 153238668 -> 153005284 (-0.15%) Instrs: 29066198 -> 29007852 (-0.20%) Latency: 133626003 -> 133598182 (-0.02%); split: -0.02%, +0.00% InvThroughput: 20208765 -> 20208689 (-0.00%) Branches: 1190209 -> 1131863 (-4.90%) Signed-off-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/13383>
This commit is contained in:
parent
baab6f18c9
commit
b731be2e96
1 changed files with 8 additions and 0 deletions
|
|
@ -420,6 +420,14 @@ try_optimize_branching_sequence(ssa_elimination_ctx& ctx, Block& block, const in
|
||||||
copy->operands[0] = Operand(exec, ctx.program->lane_mask);
|
copy->operands[0] = Operand(exec, ctx.program->lane_mask);
|
||||||
block.instructions.insert(it, std::move(copy));
|
block.instructions.insert(it, std::move(copy));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (exec_val->opcode == aco_opcode::p_parallelcopy && exec_val->operands[0].isConstant() &&
|
||||||
|
exec_val->operands[0].constantValue()) {
|
||||||
|
/* Remove the branch instruction when exec is constant non-zero. */
|
||||||
|
aco_ptr<Instruction>& branch = block.instructions.back();
|
||||||
|
if (branch->isBranch() && branch->operands.size() && branch->operands[0].physReg() == exec)
|
||||||
|
block.instructions.back().reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue