nir: calculate trip count for more loops

This adds support to loop analysis for loops where the induction
variable is compared to the result of min(variable, constant).

For example:

   for (int i = 0; i < imin(x, 4); i++)
      ...

We add a new bool to the loop terminator struct in order to
differentiate terminators with this exit condition.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
Timothy Arceri
2018-11-20 13:45:58 +11:00
parent e8a8937a04
commit 68ce0ec222
3 changed files with 49 additions and 6 deletions

View File

@@ -1912,6 +1912,17 @@ typedef struct {
bool continue_from_then;
bool induction_rhs;
/* This is true if the terminators exact trip count is unknown. For
* example:
*
* for (int i = 0; i < imin(x, 4); i++)
* ...
*
* Here loop analysis would have set a max_trip_count of 4 however we dont
* know for sure that this is the exact trip count.
*/
bool exact_trip_count_unknown;
struct list_head loop_terminator_link;
} nir_loop_terminator;