From 43cb42df7c522c261579ff234e6903bb8159936f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 13 Mar 2023 19:46:46 -0700 Subject: [PATCH] intel/compiler: Micro optimize inst_is_in_block MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This function only exists in builds with assertions, so it only matters there. On my Ice Lake laptop (using a locked CPU speed and other measures to prevent thermal throttling, etc.) using a debugoptimized build, improves performance of Vulkan CTS "deqp-vk --deqp-case='dEQP-VK.*spir*'" by -5.2% ± 0.16% (n = 5, pooled s = 0.657887). Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/compiler/brw_shader.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/intel/compiler/brw_shader.cpp b/src/intel/compiler/brw_shader.cpp index bf12c95d01f..bbca3483371 100644 --- a/src/intel/compiler/brw_shader.cpp +++ b/src/intel/compiler/brw_shader.cpp @@ -1153,11 +1153,16 @@ backend_instruction::is_volatile() const static bool inst_is_in_block(const bblock_t *block, const backend_instruction *inst) { - foreach_inst_in_block (backend_instruction, i, block) { - if (inst == i) - return true; - } - return false; + const exec_node *n = inst; + + /* Find the tail sentinel. If the tail sentinel is the sentinel from the + * list header in the bblock_t, then this instruction is in that basic + * block. + */ + while (!n->is_tail_sentinel()) + n = n->get_next(); + + return n == &block->instructions.tail_sentinel; } #endif