nir/uub: guard against division by 0

Fixes: 8ee5440073 ("nir/uub: improve ishl/imul with constant sources")

Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36805>
(cherry picked from commit de3d04dd72)
This commit is contained in:
Georg Lehmann 2025-08-17 21:53:26 +02:00 committed by Eric Engestrom
parent dbdb297b3d
commit e016f3ff19
2 changed files with 3 additions and 3 deletions

View file

@ -1134,7 +1134,7 @@
"description": "nir/uub: guard against division by 0",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "8ee54400733f1f26e175c0065ad69e6a49402969",
"notes": null

View file

@ -1895,10 +1895,10 @@ get_alu_uub(struct analysis_state *state, struct uub_query q, uint32_t *result,
nir_scalar src1_scalar = nir_scalar_chase_alu_src(q.scalar, 1);
if (nir_scalar_is_const(src0_scalar)) {
uint32_t const_val = nir_scalar_as_uint(src0_scalar);
*result = MIN2(*result, max / const_val * const_val);
*result = const_val ? MIN2(*result, max / const_val * const_val) : 0;
} else if (nir_scalar_is_const(src1_scalar)) {
uint32_t const_val = nir_scalar_as_uint(src1_scalar);
*result = MIN2(*result, max / const_val * const_val);
*result = const_val ? MIN2(*result, max / const_val * const_val) : 0;
}
break;
}