nir: Support lowering vote intrinsics
authorMatt Turner <mattst88@gmail.com>
Thu, 22 Jun 2017 19:20:18 +0000 (12:20 -0700)
committerMatt Turner <mattst88@gmail.com>
Thu, 20 Jul 2017 23:56:49 +0000 (16:56 -0700)
... trivially (as allowed by the spec!) by reusing the existing
nir_opt_intrinsics code.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/compiler/nir/nir.h
src/compiler/nir/nir_opt_intrinsics.c

index 44a1d0887e3137f2a02b6ffb45985c87e373fedf..c5e5358aaaabb9b6ace778381190e164ba43a252 100644 (file)
@@ -1821,6 +1821,8 @@ typedef struct nir_shader_compiler_options {
    bool lower_extract_byte;
    bool lower_extract_word;
 
+   bool lower_vote_trivial;
+
    /**
     * Does the driver support real 32-bit integers?  (Otherwise, integers
     * are simulated by floats.)
index 9055c98dd336aea9bff76b79a382c67acfdc6cbe..bdb46e9300bc94ed523d96336e04374e8ed403eb 100644 (file)
@@ -48,7 +48,7 @@ opt_intrinsics_impl(nir_function_impl *impl)
          case nir_intrinsic_vote_any:
          case nir_intrinsic_vote_all: {
             nir_const_value *val = nir_src_as_const_value(intrin->src[0]);
-            if (!val)
+            if (!val && !b.shader->options->lower_vote_trivial)
                continue;
 
             replacement = nir_ssa_for_src(&b, intrin->src[0], 1);
@@ -56,7 +56,7 @@ opt_intrinsics_impl(nir_function_impl *impl)
          }
          case nir_intrinsic_vote_eq: {
             nir_const_value *val = nir_src_as_const_value(intrin->src[0]);
-            if (!val)
+            if (!val && !b.shader->options->lower_vote_trivial)
                continue;
 
             replacement = nir_imm_int(&b, NIR_TRUE);