------- Comment #3 from rakdver at gcc dot gnu dot org  2009-08-07 08:44 -------
(In reply to comment #1)
> The tree optimizers canonicalize the loop to
> 
> <bb 3>:
>   # i_5 = PHI <i_3(4), 0(2)>
>   # ivtmp.23_1 = PHI <ivtmp.23_4(4), 10(2)>
>   f2 ();
>   i_3 = i_5 + 1;
>   ivtmp.23_4 = ivtmp.23_1 - 1;
>   if (ivtmp.23_4 != 0)
>     goto <bb 4>;
>   else
>     goto <bb 5>;
> 
> <bb 4>:
>   goto <bb 3>;
> 
> But then IVOPTs chooses i as the induction variable again.

This is what I would expect it to do (I am somewhat surprised that 3.3 did
something else).  Ivopts at the moment do not know that comparing with 0 is
more efficient than comparing with any other expression.  In all other aspects,
i and ivtmp.23 have the same cost, so ivopts prefers to preserve the original
induction variable.

Altering determine_use_iv_cost_condition to take the cost of the comparison
into account should fix this.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40886

Reply via email to