nir/algebraic: refactor inexact opcode restrictions
authorSamuel Iglesias Gonsálvez <siglesias@igalia.com>
Thu, 19 Sep 2019 10:10:27 +0000 (12:10 +0200)
committerSamuel Iglesias Gonsálvez <siglesias@igalia.com>
Thu, 19 Sep 2019 16:57:27 +0000 (18:57 +0200)
Refactor the code to avoid calling a lot of time to auxiliary functions
when it is not really needed.

Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/compiler/nir/nir_algebraic.py

index 783d0b692851dd926a15b60d6ae337e7094eefec..fe66952ba16fce8623f563b27517100139023eb5 100644 (file)
@@ -1169,6 +1169,10 @@ ${pass_name}_block(nir_builder *build, nir_block *block,
          continue;
 
       unsigned bit_size = alu->dest.dest.ssa.bit_size;
+      const bool ignore_inexact =
+         nir_is_float_control_signed_zero_inf_nan_preserve(execution_mode, bit_size) ||
+         nir_is_denorm_flush_to_zero(execution_mode, bit_size);
+
       switch (states[alu->dest.dest.ssa.index]) {
 % for i in range(len(automaton.state_patterns)):
       case ${i}:
@@ -1176,9 +1180,7 @@ ${pass_name}_block(nir_builder *build, nir_block *block,
          for (unsigned i = 0; i < ARRAY_SIZE(${pass_name}_state${i}_xforms); i++) {
             const struct transform *xform = &${pass_name}_state${i}_xforms[i];
             if (condition_flags[xform->condition_offset] &&
-                !(xform->search->inexact &&
-                  (nir_is_float_control_signed_zero_inf_nan_preserve(execution_mode, bit_size) ||
-                   nir_is_denorm_flush_to_zero(execution_mode, bit_size))) &&
+                !(xform->search->inexact && ignore_inexact) &&
                 nir_replace_instr(build, alu, xform->search, xform->replace)) {
                progress = true;
                break;