[Mesa-dev] [PATCH 02/10] nir: Add a loop analysis pass

Erik Faye-Lund kusmabite at gmail.com
Fri Sep 16 15:01:25 UTC 2016


On Thu, Sep 15, 2016 at 9:03 AM, Timothy Arceri
<timothy.arceri at collabora.com> wrote:
> +   const int bias[] = { -1, 1, 1 };
> +
> +   for (unsigned i = 0; i < ARRAY_SIZE(bias); i++) {
> +      iter_int = iter_int + bias[i];
> +
> +      switch (cond_op) {
> +      case nir_op_ige:
> +      case nir_op_ilt:
> +      case nir_op_ieq:
> +      case nir_op_ine:
> +         if (itest_interations(iter_int, step, limit, cond_op, initial_val,
> +                               limit_rhs)) {
> +            return iter_int;
> +         }
> +         break;
> +      case nir_op_uge:
> +      case nir_op_ult:
> +         if (utest_interations(iter_int, step, limit, cond_op,
> +                               (uint32_t) initial_val, limit_rhs)) {
> +            return iter_int;
> +         }
> +         break;
> +      default:
> +         return -1;
> +      }
> +   }

Can't this be easier written as:

for (int i = iter_int - 1; i <= iter_int + 1; ++i)
{
    switch (cond_op) {
    [...]
    if (itest_interations(i, step, limit, cond_op, initial_val, limit_rhs))
         return i;
[...]
?


More information about the mesa-dev mailing list