ivopts improvement

Paolo Bonzini bonzini@gnu.org
Thu Mar 3 08:45:00 GMT 2011


On 03/02/2011 11:01 PM, Tom de Vries wrote:
> +  if (TREE_CODE (nit) == COND_EXPR)
> +    {
> +      if (!loop_only_exit_p (loop, exit))
> +        return false;
> +
> +      return iv_elimination_compare_lt (use, cand, bound, nit, comp);
> +    }
> +

You probably need a comment on top of iv_elimination_compare_lt, 
otherwise I'm left wondering why this isn't

   if (TREE_CODE (nit) == COND_EXPR
       && loop_only_exit_p (loop, exit)
       && iv_elimination_compare_lt (use, cand, bound, nit, comp))
     return true;

Also, the check on nit is an optimization.  Perhaps you should add a 
gcc_checking_assert to i_elimination_compare_lt and/or remove this from 
get_lt_bound:

> +  if (TREE_CODE (nit) != COND_EXPR)
> +    return NULL_TREE;
> +

Or perhaps loop_only_exit_p could be optimized by computing it ahead of 
time, possibly at the same time as loop_body_includes_call.  This way it 
becomes very cheap and the code above can just call 
iv_elimination_compare_lt without any pre-screening.

Paolo



More information about the Gcc-patches mailing list