On Wed, 21 Mar 2012, Razya Ladelsky wrote:
> I need to use do_while_loop_p, but I'm not sure its functionality is what
> I expected it to be.
> This is the part that I do not understand:
> /* If the header contains just a condition, it is not a do-while loop. */
> stmt = last_and_only_stmt (loop->header);
> if (stmt
> && gimple_code (stmt) == GIMPLE_COND)
> return false;
> The header could contain a condition which is not the loop's exit
> but rather a part of its body, then why do we rule out this loop as a
> do_while loop?
> I ran into this in a loop (the outer loop) extracted from bwaves
> do k=1,nz
> do j=1,ny
> which was translated to:
> D.2361_17 = *ny_16(D);
> <bb 5>:
> # k_3 = PHI <1(4), k_562(25)>
> if (D.2361_17 > 0)
> goto <bb 8>;
> goto <bb 6>;
> <bb 6>:
> k_562 = k_3 + 1;
> # DEBUG k => k_562
> if (k_3 == D.1583_270)
> goto <bb 7>; -------> return
> goto <bb 25>;
> <bb 25>:
> goto <bb 5>;
> <bb 8>: --> starting the body of the the second loop
> pretmp.318_776 = (integer(kind=8)) k_3;
> pretmp.318_777 = stride.92_20 * pretmp.318_776;
> bb 5 is the header of the outer loop, and bb 25 is the latch.
> According to do_while_loop_p () this is NOT a do while loop, but it
> seems that it should be.
> I am attaching a patch to change do_while_loop_p() assuming that what I
> understand is indeed correct,
> Please let me know if I'm right,
Not sure what your new tests should do - the patch lacks an update
to the comment. Note that this predicate is first of all used
in loop header copying to say whether we should avoid copying
a header. In this case the condition is not what should prevent
copying of the header, but your patch seems to make it so, no?
So, please clarify your change.