nir: simplify atan range reduction fixup

the original version sure is creative.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30934>
This commit is contained in:
Alyssa Rosenzweig
2024-08-29 19:19:50 -04:00
committed by Marge Bot
parent 87b99d5797
commit 5318b8868b

View File

@@ -202,10 +202,8 @@ nir_atan(nir_builder *b, nir_def *y_over_x)
nir_def *tmp = nir_fmul(b, nir_fabs(b, u), res);
/* range-reduction fixup */
tmp = nir_ffma(b,
nir_b2fN(b, nir_flt(b, one, abs_y_over_x), bit_size),
nir_ffma_imm12(b, tmp, -2.0f, M_PI_2),
tmp);
tmp = nir_bcsel(b, nir_flt(b, one, abs_y_over_x),
nir_fsub_imm(b, M_PI_2, tmp), tmp);
/* sign fixup */
nir_def *result = nir_copysign(b, tmp, y_over_x);