This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [tree-ssa] PATCH to &&/|| gimplification


On Tue, May 20, 2003 at 04:17:41PM -0400, Jason Merrill wrote:
>   int main()
>   {
>     int i = 0;
>     int j;
>     while (1)
>       {
>         if (i>2)
>           break;
>         j = i;
>         ++i;
>       }
>     return j;
>   }
> 
> The RTL loop optimizer isn't clever enough to know that we will always
> execute the loop at least once, so j will always be initialized before use.

This is because the loop rotation code in expand_end_loop doesn't fire.
Which is because we don't emit a NOTE_INSN_LOOP_END_TOP_COND note.  See
the commentary there and in the gcc-patches message that created
NOTE_INSN_END_TOP_COND for why.

> I think this bug needs to be fixed in the loop optimizer.

Not possible, IMO, for the reasons listed indirectly above.

The gimplifier either needs to rotate the loop itself, i.e. generate

	if (i > 2)
	  do {
	    // ...
	  } while (i <= 2);

or leave simple conditionals in the WHILE_COND, or... I dunno.


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]