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

Timothy Arceri timothy.arceri at collabora.com
Sat Aug 27 06:03:26 UTC 2016


This will be used by the loop unroll and lcssa passes.
---
 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 f85e829..6b0a73f 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2614,6 +2614,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