Mesa (master): nir/unsigned_upper_bound: decrement num_sources_left before recursing

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Nov 25 13:13:20 UTC 2020


Module: Mesa
Branch: master
Commit: 2a1238f3a36f3a40cc709b1a76c7f4e920d4d528
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2a1238f3a36f3a40cc709b1a76c7f4e920d4d528

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Tue Nov 24 14:53:04 2020 +0000

nir/unsigned_upper_bound: decrement num_sources_left before recursing

Otherwise, search_phi_bcsel() will be called with a buf_size that is
slightly lower than it has to be.

Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7748>

---

 src/compiler/nir/nir_range_analysis.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_range_analysis.c b/src/compiler/nir/nir_range_analysis.c
index 04449a91232..ef7a4cdea89 100644
--- a/src/compiler/nir/nir_range_analysis.c
+++ b/src/compiler/nir/nir_range_analysis.c
@@ -1116,11 +1116,12 @@ search_phi_bcsel(nir_ssa_scalar scalar, nir_ssa_scalar *buf, unsigned buf_size,
       if (buf_size >= num_sources_left) {
          unsigned total_added = 0;
          nir_foreach_phi_src(src, phi) {
+            num_sources_left--;
             unsigned added = search_phi_bcsel(
                (nir_ssa_scalar){src->src.ssa, 0}, buf + total_added, buf_size - num_sources_left, visited);
+            assert(added <= buf_size);
             buf_size -= added;
             total_added += added;
-            num_sources_left--;
          }
          return total_added;
       }



More information about the mesa-commit mailing list