nir: always attempt to find loop terminators
authorTimothy Arceri <tarceri@itsqueeze.com>
Sat, 7 Jul 2018 02:02:08 +0000 (12:02 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Wed, 29 Aug 2018 06:02:05 +0000 (16:02 +1000)
This will help later patches with unrolling loops that end with a
break i.e. loops the always exit on their first interation.

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

index d564296aa678f5627a58dd044aa21b633d54b54f..5454b7691ba3ec652fce283f2535be3593f9bac3 100644 (file)
@@ -717,13 +717,6 @@ get_loop_info(loop_info_state *state, nir_function_impl *impl)
       }
    }
 
-   /* Induction analysis needs invariance information so get that first */
-   compute_invariance_information(state);
-
-   /* We have invariance information so try to find induction variables */
-   if (!compute_induction_information(state))
-      return;
-
    /* Try to find all simple terminators of the loop. If we can't find any,
     * or we find possible terminators that have side effects then bail.
     */
@@ -737,6 +730,13 @@ get_loop_info(loop_info_state *state, nir_function_impl *impl)
       return;
    }
 
+   /* Induction analysis needs invariance information so get that first */
+   compute_invariance_information(state);
+
+   /* We have invariance information so try to find induction variables */
+   if (!compute_induction_information(state))
+      return;
+
    /* Run through each of the terminators and try to compute a trip-count */
    find_trip_count(state);