[Mesa-dev] [PATCH 30/30] i965/fs: Calculate num_instructions in O(1) during register pressure calculation.

Francisco Jerez currojerez at riseup.net
Mon Mar 14 03:47:34 UTC 2016


And mark the variable declaration as const.
---
 src/mesa/drivers/dri/i965/brw_fs.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 6de47fa..e8fad87 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -5064,9 +5064,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.7.0



More information about the mesa-dev mailing list