[Mesa-dev] [PATCH v2 08/29] nir/algebraic: disable inexact optimizations if SHADER_SIGNED_ZERO_INF_NAN_PRESERVE is enabled

Samuel Iglesias Gonsálvez siglesias at igalia.com
Tue Dec 18 10:34:03 UTC 2018


Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
---
 src/compiler/nir/nir_algebraic.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py
index a667c4170f1..9d2b248a1c1 100644
--- a/src/compiler/nir/nir_algebraic.py
+++ b/src/compiler/nir/nir_algebraic.py
@@ -678,7 +678,7 @@ static const struct transform ${pass_name}_${opcode}_xforms[] = {
 
 static bool
 ${pass_name}_block(nir_builder *build, nir_block *block,
-                   const bool *condition_flags)
+                   const bool *condition_flags, unsigned execution_mode)
 {
    bool progress = false;
 
@@ -696,6 +696,7 @@ ${pass_name}_block(nir_builder *build, nir_block *block,
          for (unsigned i = 0; i < ARRAY_SIZE(${pass_name}_${opcode}_xforms); i++) {
             const struct transform *xform = &${pass_name}_${opcode}_xforms[i];
             if (condition_flags[xform->condition_offset] &&
+                !(xform->search->inexact && (execution_mode & SHADER_SIGNED_ZERO_INF_NAN_PRESERVE)) &&
                 nir_replace_instr(build, alu, xform->search, xform->replace)) {
                progress = true;
                break;
@@ -712,7 +713,7 @@ ${pass_name}_block(nir_builder *build, nir_block *block,
 }
 
 static bool
-${pass_name}_impl(nir_function_impl *impl, const bool *condition_flags)
+${pass_name}_impl(nir_function_impl *impl, const bool *condition_flags, unsigned execution_mode)
 {
    bool progress = false;
 
@@ -720,7 +721,7 @@ ${pass_name}_impl(nir_function_impl *impl, const bool *condition_flags)
    nir_builder_init(&build, impl);
 
    nir_foreach_block_reverse(block, impl) {
-      progress |= ${pass_name}_block(&build, block, condition_flags);
+      progress |= ${pass_name}_block(&build, block, condition_flags, execution_mode);
    }
 
    if (progress)
@@ -737,6 +738,7 @@ ${pass_name}(nir_shader *shader)
    bool progress = false;
    bool condition_flags[${len(condition_list)}];
    const nir_shader_compiler_options *options = shader->options;
+   const unsigned execution_mode = shader->info.shader_float_controls_execution_mode;
    (void) options;
 
    % for index, condition in enumerate(condition_list):
@@ -745,7 +747,7 @@ ${pass_name}(nir_shader *shader)
 
    nir_foreach_function(function, shader) {
       if (function->impl)
-         progress |= ${pass_name}_impl(function->impl, condition_flags);
+         progress |= ${pass_name}_impl(function->impl, condition_flags, execution_mode);
    }
 
    return progress;
-- 
2.19.1



More information about the mesa-dev mailing list