Patch to handle perfect loop unrolling in tree_transform_and_unroll_loop

Jean Christophe Beyler
Wed Oct 28 17:26:00 GMT 2009

> You are right. These lines are leftover of previous atttempt to merge code.
> Removed now in new patch.

Actually (again just looking at your patch code, have not tested), but now:

- Since you removed that code, new_exit does not get set at the
perfect_unrolling case. The call to tree_duplicate_loop_to_header_edge
now has new_exit passed as NULL instead of being set to either exit or
single_dom_exit like you did before.

>> - More to the point, I did something similar except I added a test to
>> see if the factor requested by the user was above the limit of
>> n_iters. If so, I say that the unrolling is perfect and issue a
>> warning.
> Can the check be done in unrolling pass?
> Does your test case only work with an extra unrolling pass? Or can be
> tested with this patch only? Currently, tree_transform_and_unroll_loop
> seems to be called by prefetch pass only.

You've got a point, I was thinking of my code where the user can
request an unrolling of a higher degree

#pragma unroll 100
for (i=0; i<20; i++)

Your patch won't unroll it at all.

However, in the case where this patch is only to fix the current code,
I don't think the unrolling passes would ever ask to unroll more than
the known iterations, so this is not a problem.

> BTW: the following lines in original tree_transform_and_unroll_loop (I didn't change) are problematic. Some complex loops won't
> meet requirements of single_pred(loop->latch) (e.g., 20060905-1.c) should this function is called to unroll them.

I don't understand this. Can you explain a bit more ?

I looked at this, my modified version 4.3.2 does not have any issues
with this test. Without my pragma, it does not try to unroll, with it,
it does not fail.


More information about the Gcc-patches mailing list