This is the mail archive of the 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]

Correcting transform_to_exit_first_loop + fix to PR46886


This patch handles duplicating of the last iteration correctly.
The current code always duplicates the complete "static"  iteration from 
the entry to the latch,
and then sets the number of iterations according to the pattern of the 
loop (according to whether the cond before the body, or the body before 
the cond).

The correct way to go about is to not assume anything about the control 
flow of the loop, and  duplicate the last iteration only from 
entry to the block consisting of the cond, that is the real last dynamic 
iteration that would be executed.
The number of iterations then needs no special care for each loop pattern.
This was actually Zdenek's original intent by duplicating the last 

This code allows us to remove the do_while cond, and gets PR46886 resolved 
(instead of the solution suggested in, 
which handled the number of iterations according to the specific shape of 
the loop)

Bootstrap and testsuite pass successfully.
Testsuite with -ftree-parallelize-loops=4 shows only one regression which 
is uninit-17.c test for warnings, which seems
unrelated to how the loop gets parallelized.
I also ran spec-2006, and it showed no regressions.

2012-04-20  Razya Ladelsky  <>
                 PR tree-optimization/46886
                 * tree-parloops.c (transform_to_exit_first_loop): Remove 
setting of number of iterations according to the loop pattern.
                 Duplicate from entry to exit->src instead of loop->latch.
                 (pallelize_loops): Remove the condition preventing 
do-while loops.
                 * tree-cfg.c (bool bb_in_region_p): New.
                 (gimple_duplicate_sese_tail): Adjust duplication of the 
the subloops.
                 Adjust redirection of the duplicated iteration. 

O.K to commit?

Attachment: dup_last_iter_fix.txt
Description: Text document

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