nir: add complex_loop bool to loop info
authorTimothy Arceri <tarceri@itsqueeze.com>
Sat, 7 Jul 2018 02:09:26 +0000 (12:09 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Wed, 29 Aug 2018 06:02:05 +0000 (16:02 +1000)
In order to be sure loop_terminator_list is an accurate
representation of all the jumps in the loop we need to be sure we
didn't encounter any other complex behaviour such as continues,
nested breaks, etc during analysis.

This will be used in the following patch.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/nir/nir.h
src/compiler/nir/nir_loop_analyze.c

index 009a6d60371e05be9567ce9d1c777989dad2b313..12cad6029cdc4b1fe177dd3b9cf6024dc23162a0 100644 (file)
@@ -1801,6 +1801,12 @@ typedef struct {
    /* Unroll the loop regardless of its size */
    bool force_unroll;
 
+   /* Does the loop contain complex loop terminators, continues or other
+    * complex behaviours? If this is true we can't rely on
+    * loop_terminator_list to be complete or accurate.
+    */
+   bool complex_loop;
+
    nir_loop_terminator *limiting_terminator;
 
    /* A list of loop_terminators terminating this loop. */
index 5454b7691ba3ec652fce283f2535be3593f9bac3..9c3fd2f286fbc7f43304b10b4831a3fe36a41238 100644 (file)
@@ -317,15 +317,19 @@ find_loop_terminators(loop_info_state *state)
           * not find a loop terminator, but there is a break-statement then
           * we should return false so that we do not try to find trip-count
           */
-         if (!nir_is_trivial_loop_if(nif, break_blk))
+         if (!nir_is_trivial_loop_if(nif, break_blk)) {
+            state->loop->info->complex_loop = true;
             return false;
+         }
 
          /* Continue if the if contained no jumps at all */
          if (!break_blk)
             continue;
 
-         if (nif->condition.ssa->parent_instr->type == nir_instr_type_phi)
+         if (nif->condition.ssa->parent_instr->type == nir_instr_type_phi) {
+            state->loop->info->complex_loop = true;
             return false;
+         }
 
          nir_loop_terminator *terminator =
             rzalloc(state->loop->info, nir_loop_terminator);