[Bug tree-optimization/42906] [4.5 Regression] Empty loop not removed

rguenther at suse dot de gcc-bugzilla@gcc.gnu.org
Wed Mar 17 10:01:00 GMT 2010



------- Comment #19 from rguenther at suse dot de  2010-03-17 10:01 -------
Subject: Re:  [4.5 Regression] Empty loop not
 removed

On Wed, 17 Mar 2010, changpeng dot fang at amd dot com wrote:

> 
> 
> ------- Comment #17 from changpeng dot fang at amd dot com  2010-03-17 00:18 -------
> (In reply to comment #8)
> > And
> > 
> > int foo (int b, int j)
> > {
> >   if (b)
> >     {
> >       int i;
> >       for (i = 0; i<1000; ++i)
> >         ;
> >       j = b;
> >     }
> >   return j;
> > }
> > 
> 
> With "j=b", "b" is not folded as a phi argument: 
> 
> <bb 5>:
>   # i_2 = PHI <0(3), i_6(4)>
>   if (i_2 <= 999)
>     goto <bb 4>;
>   else
>     goto <bb 6>;
> 
> <bb 6>:
>   j_7 = b_3(D);
> 
> <bb 7>:
>   # j_1 = PHI <j_4(D)(2), j_7(6)>
> 
> However, if "j=0", it is:
> <bb 6>:
>   j_7 = 0;
> 
> <bb 7>:
>   # j_1 = PHI <j_4(D)(2), 0(6)>
>   j_8 = j_1;
>   return j_8;
> 
> Then copy propagation will remove "j_7 = 0" (and thus <bb 6>) because it has no
> user.
> 
> So, one possible solution is "do not remove trival dead code" in
> copy_propagation pass. Any dce pass will remove such code.
> 
> Of course, if we follow Steven's suggestion not use constants as phi arguments,
> "j_7=0" will not be removed by constant propagation, and we are all fine.

Splitting critical edges for CDDCE will probably also solve this problem.

Richard.


-- 


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



More information about the Gcc-bugs mailing list