nir: simplify atan range reduction

just implement what the comment says, don't be clever. the clever thing is worse
on all architectures i'm familiar with, because the fdiv will turn into
fmul+frcp.

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:02:29 -04:00 committed by Marge Bot
parent a32b1a975d
commit 8579375777

View file

@ -174,8 +174,8 @@ nir_atan(nir_builder *b, nir_def *y_over_x)
* x = <
* \ 1.0 / |y_over_x| otherwise
*/
nir_def *x = nir_fdiv(b, nir_fmin(b, abs_y_over_x, one),
nir_fmax(b, abs_y_over_x, one));
nir_def *x = nir_bcsel(b, nir_fle_imm(b, abs_y_over_x, 1.0),
abs_y_over_x, nir_frcp(b, abs_y_over_x));
/*
* approximate atan by evaluating polynomial using Horner's method: