Hi,
> >> + /* Determine if the exit test is formulated in terms of the phi or the
> >> + increment of the use iv. */
> >> + use_uses_inced_iv
> >> + = gimple_code (SSA_NAME_DEF_STMT (use->iv->ssa_name)) != GIMPLE_PHI;
> >> +
> >> + /* Determine if the exit test is before or after the increment of the
> >> + cand. */
> >> + use_after_cand_inc
> >> + = stmt_after_increment (data->current_loop, cand, use->stmt);
> >> +
> >> + /* For now, we only handle these cases. */
> >> + if (use_after_cand_inc != use_uses_inced_iv)
> >> + return false;
> >
> > what is this trying to achieve? USE_USES_INCED_IV is pretty much
> > meaningless --
> > the value of USE does not depend in any way on whether it comes
> > directly from
> > a PHI node or from some other calculation.
>
> it is trying to allow for
>
> do
> {
> *p = '\0';
> i++; /* use_uses_inced_iv == true */
> p++; /* use_after_cand_inc == true */
> if (!(i < n))
> break;
> }
> while (1);
>
> and for
>
> do
> {
> *p = '\0';
> if (!(i < n))
> break;
> i++; /* use_uses_inced_iv == false */
> p++; /* use_after_cand_inc == false */
> }
> while (1);
>
> but not for
>
> do
> {
> *p = '\0';
> i++; /* use_uses_inced_iv == true */
> if (!(i < n))
> break;
> p++; /* use_after_cand_inc == false */
> }
> while (1);
>
> and not for
>
> do
> {
> *p = '\0';
> p++; /* use_after_cand_inc == true */
> if (!(i < n))
> break;
> i++; /* use_uses_inced_iv == false */
> }
> while (1);
>
> In the latter 2 cases, I cannot simply replace i < n with p < base + n.
Why not (other than that the value to compare with varies in these cases, but
it always is "the value of p in the last iteration of the loop")?
One more thing: what is fold_walk_def_plus for?
Zdenek