<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 23, 2018 at 1:38 AM Connor Abbott <<a href="mailto:cwabbott0@gmail.com">cwabbott0@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Tue, Oct 23, 2018 at 12:16 AM Jason Ekstrand <<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>> wrote:<br>
><br>
> D3D booleans use a 32-bit 0/-1 representation.  Because this previously<br>
> matched NIR exactly, we didn't have to really optimize for it.  Now that<br>
> we have 1-bit booleans, we need some specific optimizations to chew<br>
> through the D3D12-style booleans.<br>
> ---<br>
>  src/compiler/nir/nir_opt_algebraic.py | 13 +++++++++++++<br>
>  1 file changed, 13 insertions(+)<br>
><br>
> diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py<br>
> index f0861c4411d..4d778e4b308 100644<br>
> --- a/src/compiler/nir/nir_opt_algebraic.py<br>
> +++ b/src/compiler/nir/nir_opt_algebraic.py<br>
> @@ -239,6 +239,7 @@ optimizations = [<br>
>     (('fne', ('b2f', a), 0.0), a),<br>
>     (('ieq', ('b2i', a), 0),   ('inot', a)),<br>
>     (('ine', ('b2i', a), 0),   a),<br>
> +   (('ine', ('ineg', ('b2i', a)), 0), a),<br>
><br>
>     (('fne', ('u2f32', a), 0.0), ('ine', a, 0)),<br>
>     (('feq', ('u2f32', a), 0.0), ('ieq', a, 0)),<br>
> @@ -528,6 +529,18 @@ optimizations = [<br>
>     (('bcsel', a, b, b), b),<br>
>     (('fcsel', a, b, b), b),<br>
><br>
> +   # D3D Boolean eumulation<br>
> +   (('bcsel', a, -1, 0), ('ineg', ('b2i', a))),<br>
> +   (('bcsel', a, 0, -1), ('ineg', ('b2i', ('inot', a)))),<br>
> +   (('iand', ('ineg', ('b2i', a)), ('ineg', ('b2i', b))),<br>
> +    ('ineg', ('b2i', ('iand', a, b)))),<br>
> +   (('ior', ('ineg', ('b2i', a)), ('ineg', ('b2i', b))),<br>
> +    ('ineg', ('b2i', ('ior', a, b)))),<br>
> +   (('ieq', ('ineg', ('b2i', a)), 0), ('inot', a)),<br>
> +   (('ieq', ('ineg', ('b2i', a)), -1), a),<br>
> +   (('ine', ('ineg', ('b2i', a)), 0), a),<br>
<br>
Isn't this the same as the line you added above?<br></blockquote><div><br></div><div>Yes, it is.  I've deleted the top one locally.</div><div><br></div><div>--Jason<br></div></div></div>