[Mesa-dev] [PATCH 04/13] nir: add is_simple_for_loop() helper

Timothy Arceri timothy.arceri at collabora.com
Mon Aug 29 04:59:12 UTC 2016


This will be used by the loop unroll and lcssa passes.

Reviewed-by: Thomas Helland <thomashelland90 at gmail.com>
---
 src/compiler/nir/nir.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 491859e..0ddd4e2 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2627,6 +2627,14 @@ bool nir_normalize_cubemap_coords(nir_shader *shader);
 
 void nir_live_ssa_defs_impl(nir_function_impl *impl);
 
+static inline bool
+is_simple_for_loop(nir_shader *shader, nir_loop_info *li)
+{
+   unsigned max_iter = shader->options->max_unroll_iterations;
+   return li->is_trip_count_known && li->trip_count < max_iter &&
+          list_is_singular(&li->loop_terminator_list);
+}
+
 void nir_loop_analyze_impl(nir_function_impl *impl);
 void nir_loop_analyze(nir_shader *shader);
 
-- 
2.7.4



More information about the mesa-dev mailing list