From 70349a2252a95f181de519be61ea84bd22381e4b Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Sun, 13 Mar 2016 16:37:03 -0700 Subject: [PATCH] intel/compiler: Calculate num_instructions in O(1) during register pressure calculation And mark the variable declaration as const. Reviewed-by: Matt Turner Tested-by: Marge Bot Part-of: --- src/intel/compiler/brw_fs.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp index 704088ab588..0a6537478e0 100644 --- a/src/intel/compiler/brw_fs.cpp +++ b/src/intel/compiler/brw_fs.cpp @@ -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](); -- 2.30.2