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

Author: Juan A. Suarez Romero <jasua...@igalia.com>
Date:   Thu Apr  8 11:53:50 2021 +0200

broadcom/compiler: fix first_component assertion

first_component is an uint, and thus if it takes value 0 we can't know
if it is because writemask has its first bit to 1, or all bits to 0.

As we want to ensure that at least one bit is set, apply the assertion
in writemask.

Fixes CID#1472829 "Macro compares unsigned to 0 (NO_EFFECT)".

v2:
 - Restore "first_component <= last_component" assertion (Iago)

Reviewed-by: Iago Toral Quiroga <ito...@igalia.com>
Signed-off-by: Juan A. Suarez Romero <jasua...@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10103>

---

 src/broadcom/compiler/nir_to_vir.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/broadcom/compiler/nir_to_vir.c 
b/src/broadcom/compiler/nir_to_vir.c
index 127e0ae6a6b..2fbc81c4535 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -315,13 +315,13 @@ emit_tmu_general_store_writes(struct v3d_compile *c,
          * are enabled in the writemask and emit the TMUD
          * instructions for them.
          */
+        assert(*writemask != 0);
         uint32_t first_component = ffs(*writemask) - 1;
         uint32_t last_component = first_component;
         while (*writemask & BITFIELD_BIT(last_component + 1))
                 last_component++;
 
-        assert(first_component >= 0 &&
-               first_component <= last_component &&
+        assert(first_component <= last_component &&
                last_component < instr->num_components);
 
         for (int i = first_component; i <= last_component; i++) {

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to