Module: Mesa
Branch: master
Commit: 7019cd84c0ff2e3682c91cf2ab3a50c20226d024
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7019cd84c0ff2e3682c91cf2ab3a50c20226d024

Author: Ian Romanick <[email protected]>
Date:   Mon Aug 17 15:56:24 2020 -0700

nir/search: Use range analysis for is_finite

There are only a couple patterns that use is_finite, so the changes
aren't huge.  Mostly shaders from Batman Arkham City and a few shaders
from Shadow of the Tomb Raider were affected.

Reviewed-by: Rhys Perry <[email protected]>

Tiger Lake
Instructions in all programs: 160902591 -> 160902489 (-0.0%)
SENDs in all programs: 6812270 -> 6812270 (+0.0%)
Loops in all programs: 38225 -> 38225 (+0.0%)
Cycles in all programs: 7429003266 -> 7428992369 (-0.0%)
Spills in all programs: 192582 -> 192582 (+0.0%)
Fills in all programs: 304539 -> 304539 (+0.0%)

Ice Lake
Instructions in all programs: 145301634 -> 145301460 (-0.0%)
SENDs in all programs: 6863890 -> 6863890 (+0.0%)
Loops in all programs: 38219 -> 38219 (+0.0%)
Cycles in all programs: 8798589772 -> 8798575869 (-0.0%)
Spills in all programs: 216880 -> 216880 (+0.0%)
Fills in all programs: 334250 -> 334250 (+0.0%)

Skylake
Instructions in all programs: 135892010 -> 135891836 (-0.0%)
SENDs in all programs: 6802916 -> 6802916 (+0.0%)
Loops in all programs: 38216 -> 38216 (+0.0%)
Cycles in all programs: 8442597324 -> 8442583202 (-0.0%)
Spills in all programs: 194839 -> 194839 (+0.0%)
Fills in all programs: 301116 -> 301116 (+0.0%)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9108>

---

 src/compiler/nir/nir_search_helpers.h | 30 +++++-------------------------
 1 file changed, 5 insertions(+), 25 deletions(-)

diff --git a/src/compiler/nir/nir_search_helpers.h 
b/src/compiler/nir/nir_search_helpers.h
index 5de812f1e4c..cae9ef4f0bd 100644
--- a/src/compiler/nir/nir_search_helpers.h
+++ b/src/compiler/nir/nir_search_helpers.h
@@ -422,35 +422,15 @@ is_integral(struct hash_table *ht, const nir_alu_instr 
*instr, unsigned src,
 
 /**
  * Is the value finite?
- *
- * Doesn't actually use range tracking.  Just checks that the value is a
- * constant that is finite.
  */
 static inline bool
-is_finite(UNUSED struct hash_table *ht, const nir_alu_instr *instr, unsigned 
src,
-          unsigned num_components, const uint8_t *swizzle)
+is_finite(UNUSED struct hash_table *ht, const nir_alu_instr *instr,
+          unsigned src, UNUSED unsigned num_components,
+          UNUSED const uint8_t *swizzle)
 {
-   if (nir_src_as_const_value(instr->src[src].src) == NULL)
-      return false;
-
-   for (unsigned i = 0; i < num_components; i++) {
-      nir_alu_type type = nir_op_infos[instr->op].input_types[src];
-      switch (nir_alu_type_get_base_type(type)) {
-      case nir_type_float:
-         if (!isfinite(nir_src_comp_as_float(instr->src[src].src, swizzle[i])))
-            return false;
-         break;
-      case nir_type_bool:
-      case nir_type_int:
-      case nir_type_uint:
-         /* Non-float types are always finite. */
-         break;
-      default:
-         return false;
-      }
-   }
+   const struct ssa_result_range v = nir_analyze_range(ht, instr, src);
 
-   return true;
+   return v.is_finite;
 }
 
 

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to