nir: make nir_fisnan helper exact
authorRhys Perry <pendingchaos02@gmail.com>
Thu, 30 Mar 2023 12:38:06 +0000 (13:38 +0100)
committerMarge Bot <emma+marge@anholt.net>
Mon, 10 Apr 2023 17:42:24 +0000 (17:42 +0000)
Floating point ALU assume no NaNs unless
FLOAT_CONTROLS_SIGNED_ZERO_INF_NAN_PRESERVE_FPn or (for some opcodes)
exact=true.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fixes: bf9c1699cd7 ("nir: add nir_fisnan helper function")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22206>

src/compiler/nir/nir_builtin_builder.h

index ed9d529..1082fa8 100644 (file)
@@ -56,7 +56,11 @@ nir_get_texture_size(nir_builder *b, nir_tex_instr *tex);
 static inline nir_ssa_def *
 nir_fisnan(nir_builder *b, nir_ssa_def *x)
 {
-   return nir_fneu(b, x, x);
+   bool old_exact = b->exact;
+   b->exact = true;
+   nir_ssa_def *res = nir_fneu(b, x, x);
+   b->exact = old_exact;
+   return res;
 }
 
 static inline nir_ssa_def *