Mesa (main): intel: Early exit from inst_is_in_block().

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 29 17:02:21 UTC 2021


Module: Mesa
Branch: main
Commit: b18cf54f0d558c926a17ac2ffc93d866af678d82
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b18cf54f0d558c926a17ac2ffc93d866af678d82

Author: Emma Anholt <emma at anholt.net>
Date:   Mon Jun 28 15:56:38 2021 -0700

intel: Early exit from inst_is_in_block().

Surely the compiler would sort that out, you would think.  But no, my
debugoptimized build improves
dEQP-GLES31.functional.ubo.random.all_per_block_buffers.13 runtime by 25%
on my SKL from this change.

This was the slowest test in the GLES31 tests on APL in CI, at 22s.  And
yes, we were spending around half of our runtime in this function.

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Acked-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11631>

---

 src/intel/compiler/brw_shader.cpp | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/intel/compiler/brw_shader.cpp b/src/intel/compiler/brw_shader.cpp
index fdec1d535ac..6edc53ea3dc 100644
--- a/src/intel/compiler/brw_shader.cpp
+++ b/src/intel/compiler/brw_shader.cpp
@@ -1173,13 +1173,11 @@ backend_instruction::is_volatile() const
 static bool
 inst_is_in_block(const bblock_t *block, const backend_instruction *inst)
 {
-   bool found = false;
    foreach_inst_in_block (backend_instruction, i, block) {
-      if (inst == i) {
-         found = true;
-      }
+      if (inst == i)
+         return true;
    }
-   return found;
+   return false;
 }
 #endif
 



More information about the mesa-commit mailing list