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: remove useless edge split in copy_loop_headers


Hi,

> The function copy_loop_headers after duplicate the region for a loop, 
>  
>     234             }
>     235         }
>     236
>    237       /* Ensure that the latch and the preheader is simple (we know that they
>    238          are not now, since there was the loop exit condition.  */
>    239       split_edge (loop_preheader_edge (loop));
>    240       split_edge (loop_latch_edge (loop));
>     241     }
>     242
>    243   free (bbs);
> 
> 
> In fact, the statements in line 239 and 240 are useless because there will
> be no code motion optimizing (for example loop invariant movement) related to
> that splitting in this pass, and the edges created by above statements are
> removed by cfg cleanup in execute_todo that follows. 

however, as the comment suggests, they are necessary to ensure that the
loop latch and the loop preheader have exactly one predecessor, which
are the invariants about the loop structure that we preserve.

While at the moment it indeed is not strictly necessary to enforce these
invariants at this particular point (as we do not optimize the loops
further), the code should be left there as it is; not doing so would
cause verify_loops fail after the transformation, which would make
debugging more difficult.  Also, sometime in future we may decide to do
some more complicated processing after/during loop header copying.

Do you have some reason why you want to have these statements removed
(i.e., do you see them increasing compile time/memory consumption)?

Zdenek


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