From 8579375777ed1533e4186a2834e609b284e96ef3 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 29 Aug 2024 19:02:29 -0400 Subject: [PATCH] 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 Reviewed-by: Ian Romanick Part-of: --- src/compiler/nir/nir_builtin_builder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/nir/nir_builtin_builder.c b/src/compiler/nir/nir_builtin_builder.c index ec361ddb2a9..723070c0325 100644 --- a/src/compiler/nir/nir_builtin_builder.c +++ b/src/compiler/nir/nir_builtin_builder.c @@ -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: