mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 04:58:05 +02:00
nir: Add a couple is_zero() helpers
Reviewed-by: Christoph Pillmayer <christoph.pillmayer@arm.com> Reviewed-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com> Reviewed-by: Lorenzo Rossi <lorenzo.rossi@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40769>
This commit is contained in:
parent
fd5c6d1223
commit
fb347b8458
1 changed files with 20 additions and 0 deletions
|
|
@ -3102,6 +3102,20 @@ NIR_DEFINE_SRC_AS_CONST(double, float)
|
|||
|
||||
#undef NIR_DEFINE_SRC_AS_CONST
|
||||
|
||||
static inline bool
|
||||
nir_src_is_zero(nir_src src)
|
||||
{
|
||||
if (!nir_src_is_const(src))
|
||||
return false;
|
||||
|
||||
for (unsigned i = 0; i < nir_src_num_components(src); i++) {
|
||||
if (nir_src_comp_as_uint(src, i) != 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline nir_const_value
|
||||
nir_scalar_as_const_value(nir_scalar s)
|
||||
{
|
||||
|
|
@ -3125,6 +3139,12 @@ NIR_DEFINE_SCALAR_AS_CONST(double, float)
|
|||
|
||||
#undef NIR_DEFINE_SCALAR_AS_CONST
|
||||
|
||||
static inline bool
|
||||
nir_scalar_is_zero(nir_scalar s)
|
||||
{
|
||||
return nir_scalar_is_const(s) && nir_scalar_as_uint(s) == 0;
|
||||
}
|
||||
|
||||
static inline nir_op
|
||||
nir_scalar_alu_op(nir_scalar s)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue