<div dir="ltr"><div class="gmail_quote"><div dir="ltr"></div><div>Can you provide some context for this?  Those rules are already flagged "inexact" (that's what the ~ means) so they won't apply to anything that's "precise" or "invariant".</div><div dir="ltr"><br></div><div dir="ltr">On Thu, Nov 29, 2018 at 9:18 AM Samuel Pitoiset <<a href="mailto:samuel.pitoiset@gmail.com">samuel.pitoiset@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It's correct in GLSL because the behaviour is undefined in<br>
presence of NaNs. But this seems incorrect in Vulkan.<br>
<br>
Signed-off-by: Samuel Pitoiset <<a href="mailto:samuel.pitoiset@gmail.com" target="_blank">samuel.pitoiset@gmail.com</a>><br>
---<br>
 src/compiler/nir/nir.h                | 6 ++++++<br>
 src/compiler/nir/nir_opt_algebraic.py | 8 ++++----<br>
 2 files changed, 10 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h<br>
index db935c8496b..4107c293962 100644<br>
--- a/src/compiler/nir/nir.h<br>
+++ b/src/compiler/nir/nir.h<br>
@@ -2188,6 +2188,12 @@ typedef struct nir_shader_compiler_options {<br>
    /* Set if nir_lower_wpos_ytransform() should also invert gl_PointCoord. */<br>
    bool lower_wpos_pntc;<br>
<br>
+       /* If false, lower ~inot(flt(a,b)) -> fge(a,b) and variants.<br>
+        * In presence of NaNs, this is correct in GLSL because the behaviour is<br>
+        * undefined. In Vulkan, doing these transformations is incorrect.<br>
+        */<br>
+       bool exact_float_comparisons;<br>
+<br>
    /**<br>
     * Should nir_lower_io() create load_interpolated_input intrinsics?<br>
     *<br>
diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py<br>
index f2a7be0c403..3750874407b 100644<br>
--- a/src/compiler/nir/nir_opt_algebraic.py<br>
+++ b/src/compiler/nir/nir_opt_algebraic.py<br>
@@ -154,10 +154,10 @@ optimizations = [<br>
    (('ishl', ('imul', a, '#b'), '#c'), ('imul', a, ('ishl', b, c))),<br>
<br>
    # Comparison simplifications<br>
-   (('~inot', ('flt', a, b)), ('fge', a, b)),<br>
-   (('~inot', ('fge', a, b)), ('flt', a, b)),<br>
-   (('~inot', ('feq', a, b)), ('fne', a, b)),<br>
-   (('~inot', ('fne', a, b)), ('feq', a, b)),<br>
+   (('~inot', ('flt', a, b)), ('fge', a, b), '!options->exact_float_comparisons'),<br>
+   (('~inot', ('fge', a, b)), ('flt', a, b), '!options->exact_float_comparisons'),<br>
+   (('~inot', ('feq', a, b)), ('fne', a, b), '!options->exact_float_comparisons'),<br>
+   (('~inot', ('fne', a, b)), ('feq', a, b), '!options->exact_float_comparisons'),<br></blockquote><div><br></div><div>The feq/fne one is actually completely safe.  fne is defined to be !feq even when NaN is considered.</div><div><br></div><div>--Jasoan<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    (('inot', ('ilt', a, b)), ('ige', a, b)),<br>
    (('inot', ('ult', a, b)), ('uge', a, b)),<br>
    (('inot', ('ige', a, b)), ('ilt', a, b)),<br>
-- <br>
2.19.2<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div></div>