nir: intel/vec4: Add flag to disable some algebraic optimizations
authorIan Romanick <ian.d.romanick@intel.com>
Mon, 3 Jun 2019 22:22:15 +0000 (15:22 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Thu, 11 Jul 2019 17:20:03 +0000 (10:20 -0700)
A couple patches later in this series use the flag to avoid a few
thousand shader-db regresions on all vec4 platforms.

I'm not particularly enamored with the name of this flag.  However, I
suspect the Intel vec4 backend is the only backend that will benefit
from it.  Specifically, the cases where this helps are all cases where
we want to prevent nir_opt_algebraic from rearranging instructions to
create 3-source instructions, such as ffma and flrp, with additional
immediate value or uniform sources.

The earlier commit "intel/vec4: Try to emit a single load for multiple
3-src instruction operands" solves most of the problems caused by
additional immediate values, but the restrictions on register strides
that cause problems for uniforms and shader inputs persist.

Reviewed-by: Matt Turner <mattst88@gmail.com>
src/compiler/nir/nir.h
src/intel/compiler/brw_compiler.c

index 4fa50940e174a9bb531b47429396bd5ff50ca379..bc7ae1cc03e374a684a659633ff83e9c72b26c4b 100644 (file)
@@ -2630,6 +2630,16 @@ typedef struct nir_shader_compiler_options {
    /* Lowers when rotate instruction is not supported */
    bool lower_rotate;
 
+   /**
+    * Is this the Intel vec4 backend?
+    *
+    * Used to inhibit algebraic optimizations that are known to be harmful on
+    * the Intel vec4 backend.  This is generally applicable to any
+    * optimization that might cause more immediate values to be used in
+    * 3-source (e.g., ffma and flrp) instructions.
+    */
+   bool intel_vec4;
+
    unsigned max_unroll_iterations;
 
    nir_lower_int64_options lower_int64_options;
index eb1f3808fbc657f3ab193c20e10e98f294f717d8..3a80f807b8777133039c104117b98b61124ce14b 100644 (file)
@@ -82,6 +82,7 @@ static const struct nir_shader_compiler_options vector_nir_options = {
    .lower_unpack_unorm_2x16 = true,
    .lower_extract_byte = true,
    .lower_extract_word = true,
+   .intel_vec4 = true,
    .max_unroll_iterations = 32,
 };