mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-09 23:08:18 +02:00
vtn/opencl: fix edge case behavior for tanpi
Cc: mesa-stable Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41726>
This commit is contained in:
parent
1e9b1075b6
commit
a6172f19a0
1 changed files with 15 additions and 0 deletions
|
|
@ -726,6 +726,21 @@ handle_special(struct vtn_builder *b, uint32_t opcode,
|
|||
break;
|
||||
}
|
||||
|
||||
case OpenCLstd_Tanpi: {
|
||||
if (nb->fp_math_ctrl & nir_fp_preserve_signed_zero) {
|
||||
nir_def *remainder = nir_fmod(nb, nir_fabs(nb, srcs[0]), nir_imm_floatN_t(nb, 2.0, ret->bit_size));
|
||||
nir_def *is_odd = nir_feq_imm(nb, remainder, 1.0);
|
||||
nir_def *is_even = nir_feq_imm(nb, remainder, 0.0);
|
||||
|
||||
/* tanpi(n) is copysign(0.0, - n) for odd integers n. */
|
||||
ret = nir_bcsel(nb, is_odd, nir_copysign(nb, ret, nir_fneg(nb, srcs[0])), ret);
|
||||
|
||||
/* tanpi(n) is copysign(0.0, n) for even integers n. */
|
||||
ret = nir_bcsel(nb, is_even, nir_copysign(nb, ret, srcs[0]), ret);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue