mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-06 17:30:20 +01:00
nir: Properly handle various exceptional values in frexp
frexp_sig of ±0, ±Inf, or NaN should just return the input unmodified.
frexp_exp of ±Inf or NaN is undefined, and frexp_exp of ±0 should return
the input unmodified. This seems to already work.
No shader-db or fossil-db changes on any Intel platform.
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Fixes: 23d30f4099 ("spirv,nir: lower frexp_exp/frexp_sig inside a new NIR pass")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13999>
This commit is contained in:
parent
93ed87af28
commit
7d0d9b9fbc
1 changed files with 18 additions and 6 deletions
|
|
@ -35,7 +35,6 @@ lower_frexp_sig(nir_builder *b, nir_ssa_def *x)
|
|||
nir_ssa_def *abs_x = nir_fabs(b, x);
|
||||
nir_ssa_def *zero = nir_imm_floatN_t(b, 0, x->bit_size);
|
||||
nir_ssa_def *sign_mantissa_mask, *exponent_value;
|
||||
nir_ssa_def *is_not_zero = nir_fneu(b, abs_x, zero);
|
||||
|
||||
switch (x->bit_size) {
|
||||
case 16:
|
||||
|
|
@ -89,18 +88,31 @@ lower_frexp_sig(nir_builder *b, nir_ssa_def *x)
|
|||
* 32 bits using nir_unpack_64_2x32_split_y.
|
||||
*/
|
||||
nir_ssa_def *upper_x = nir_unpack_64_2x32_split_y(b, x);
|
||||
nir_ssa_def *zero32 = nir_imm_int(b, 0);
|
||||
|
||||
/* If x is ±0, ±Inf, or NaN, return x unmodified. */
|
||||
nir_ssa_def *new_upper =
|
||||
nir_ior(b, nir_iand(b, upper_x, sign_mantissa_mask),
|
||||
nir_bcsel(b, is_not_zero, exponent_value, zero32));
|
||||
nir_bcsel(b,
|
||||
nir_iand(b,
|
||||
nir_flt(b, zero, abs_x),
|
||||
nir_fisfinite(b, x)),
|
||||
nir_ior(b,
|
||||
nir_iand(b, upper_x, sign_mantissa_mask),
|
||||
exponent_value),
|
||||
upper_x);
|
||||
|
||||
nir_ssa_def *lower_x = nir_unpack_64_2x32_split_x(b, x);
|
||||
|
||||
return nir_pack_64_2x32_split(b, lower_x, new_upper);
|
||||
} else {
|
||||
return nir_ior(b, nir_iand(b, x, sign_mantissa_mask),
|
||||
nir_bcsel(b, is_not_zero, exponent_value, zero));
|
||||
/* If x is ±0, ±Inf, or NaN, return x unmodified. */
|
||||
return nir_bcsel(b,
|
||||
nir_iand(b,
|
||||
nir_flt(b, zero, abs_x),
|
||||
nir_fisfinite(b, x)),
|
||||
nir_ior(b,
|
||||
nir_iand(b, x, sign_mantissa_mask),
|
||||
exponent_value),
|
||||
x);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue