From 87b99d579772d6ea84ae08c7e091d1ea5244b1fa Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 3 Sep 2024 09:25:45 -0400 Subject: [PATCH] nir: use copysign for atan this does two things: * ignores sign of negative numbers which let us play fast and loose later in th series * avoids an expensive fsign instruction in favour of a cheap bitwise op Signed-off-by: Alyssa Rosenzweig Reviewed-by: Ian Romanick Part-of: --- src/compiler/nir/nir_builtin_builder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_builtin_builder.c b/src/compiler/nir/nir_builtin_builder.c index 0cfe569ca55..c28d0b0beca 100644 --- a/src/compiler/nir/nir_builtin_builder.c +++ b/src/compiler/nir/nir_builtin_builder.c @@ -208,7 +208,7 @@ nir_atan(nir_builder *b, nir_def *y_over_x) tmp); /* sign fixup */ - nir_def *result = nir_fmul(b, tmp, nir_fsign(b, y_over_x)); + nir_def *result = nir_copysign(b, tmp, y_over_x); /* The fmin and fmax above will filter out NaN values. This leads to * non-NaN results for NaN inputs. Work around this by doing