intel/compiler: Calculate num_instructions in O(1) during register pressure calculation

And mark the variable declaration as const.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4012>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4012>
This commit is contained in:
Francisco Jerez
2016-03-13 16:37:03 -07:00
committed by Matt Turner
parent e5e4d016b9
commit 70349a2252

View File

@@ -7362,9 +7362,8 @@ fs_visitor::setup_cs_payload()
brw::register_pressure::register_pressure(const fs_visitor *v)
{
const fs_live_variables &live = v->live_analysis.require();
unsigned num_instructions = 0;
foreach_block(block, v->cfg)
num_instructions += block->instructions.length();
const unsigned num_instructions = v->cfg->num_blocks ?
v->cfg->blocks[v->cfg->num_blocks - 1]->end_ip + 1 : 0;
regs_live_at_ip = new unsigned[num_instructions]();