Commit Graph

22 Commits

Author SHA1 Message Date
Bill Wendling 8d1f801a01 Remove dead store.
llvm-svn: 92157
2009-12-25 13:39:58 +00:00
Chris Lattner a48f44d9ee improve portability to avoid conflicting with std::next in c++'0x.
Patch by Howard Hinnant!

llvm-svn: 90365
2009-12-03 00:50:42 +00:00
Jim Grosbach 801b33b17c Move the utility function UpdateTerminator() from CodePlacementOpt() into
MachineBasicBlock so other passes can utilize it.

llvm-svn: 86947
2009-11-12 03:55:33 +00:00
Dan Gohman c0964a571b Re-apply r84295, with fixes to how the loop "top" and "bottom" blocks are
tracked. Instead of trying to manually keep track of these locations
while doing complex modifications, just recompute them when they're needed.
This fixes a bug in which the TopMBB and BotMBB were not correctly updated,
leading to invalid transformations.

llvm-svn: 84598
2009-10-20 04:50:37 +00:00
Anton Korobeynikov 8383c3d7f3 Revert r84295, this unbreaks llvm-gcc bootstrap on x86-64/linux
llvm-svn: 84516
2009-10-19 18:21:09 +00:00
Daniel Dunbar 54279632f3 Fix my -Asserts warning fix.
llvm-svn: 84372
2009-10-17 23:15:04 +00:00
Daniel Dunbar 47dfc9ae1b Suppress -Asserts warning.
llvm-svn: 84327
2009-10-17 09:33:00 +00:00
Dan Gohman 0d3d9ee03e Enhance CodePlacementOpt's unconditional intra-loop branch elimination logic
to be more general and understand more varieties of loops.

Teach CodePlacementOpt to reorganize the basic blocks of a loop so that
they are contiguous. This also includes a fair amount of logic for preserving
fall-through edges while doing so. This fixes a BranchFolding-ism where blocks
which can't be made to use a fall-through edge and don't conveniently fit
anywhere nearby get tossed out to the end of the function.

llvm-svn: 84295
2009-10-17 00:32:43 +00:00
Dan Gohman c9af381df8 Make CodePlacementOpt align loops, rather than loop headers. The
header is just the entry block to the loop, and it needn't be at
the top of the loop in the code layout.

Remove the code that suppressed loop alignment for outer loops,
so that outer loops are aligned.

llvm-svn: 84158
2009-10-15 00:36:22 +00:00
Dan Gohman f8e4410994 Fix this comment. The loop header is the loop entry point.
llvm-svn: 83437
2009-10-07 00:33:10 +00:00
Bob Wilson d9145fca7f Fix CodePlacementOpt::OptimizeIntraLoopEdges so that its return value
correctly indicates whether it changed the code.

llvm-svn: 72038
2009-05-18 21:02:18 +00:00
Evan Cheng ab0d23396a Run code placement optimization for targets that want it (arm and x86 for now).
llvm-svn: 71726
2009-05-13 21:42:09 +00:00
Evan Cheng 85cca64dd7 If header of inner loop is aligned, do not align the outer loop header. We don't want to add nops in the outer loop for the sake of aligning the inner loop.
llvm-svn: 71609
2009-05-12 23:58:14 +00:00
Bob Wilson 9e3d48f10d Fix pr4195: When iterating through predecessor blocks, break out of the loop
after finding the (unique) layout predecessor.  Sometimes a block may be listed
more than once, and processing it more than once in this loop can lead to
inconsistent values for FtTBB/FtFBB, since the AnalyzeBranch method does not
clear these values.  There's no point in continuing the loop regardless.
The testcase for this is reduced from the 2003-05-02-DependentPHI SingleSource
test.

llvm-svn: 71536
2009-05-12 03:48:10 +00:00
Evan Cheng 9085126bee Oops. Don't forget to align single bb loops.
llvm-svn: 71363
2009-05-09 19:18:01 +00:00
Evan Cheng 51fa9c7138 Enable loop bb placement optimization.
llvm-svn: 71291
2009-05-08 23:35:49 +00:00
Evan Cheng 6e9959e327 Don't align loop header unless the loop back edge is below the header.
llvm-svn: 71242
2009-05-08 19:01:44 +00:00
Evan Cheng 5b9b33bcac Reverse branch condition only when there is a conditional branch.
llvm-svn: 71214
2009-05-08 09:35:53 +00:00
Nick Lewycky b873ed672d Add explicit braces to disambiguate nested if/else. Removes a warning.
llvm-svn: 71211
2009-05-08 06:57:41 +00:00
Evan Cheng 2fa281106a Optimize code placement in loop to eliminate unconditional branches or move unconditional branch to the outside of the loop. e.g.
///       A:                                                                                                                                                                 
///       ...                                                                                                                                                                
///       <fallthrough to B>                                                                                                                                                 
///                                                                                                                                                                          
///       B:  --> loop header                                                                                                                                                
///       ...                                                                                                                                                                
///       jcc <cond> C, [exit]                                                                                                                                               
///                                                                                                                                                                          
///       C:                                                                                                                                                                 
///       ...                                                                                                                                                                
///       jmp B                                                                                                                                                              
///                                                                                                                                                                          
/// ==>                                                                                                                                                                      
///                                                                                                                                                                          
///       A:                                                                                                                                                                 
///       ...                                                                                                                                                                
///       jmp B                                                                                                                                                              
///                                                                                                                                                                          
///       C:  --> new loop header                                                                                                                                            
///       ...                                                                                                                                                                
///       <fallthough to B>                                                                                                                                                  
///                                                                                                                                                                          
///       B:                                                                                                                                                                 
///       ...                                                                                                                                                                
///       jcc <cond> C, [exit] 

llvm-svn: 71209
2009-05-08 06:34:09 +00:00
Evan Cheng 143bae5dcd Code refactoring.
llvm-svn: 71151
2009-05-07 05:49:39 +00:00
Evan Cheng f356a89e92 Rename "loop aligner" pass to "code placement optimization" pass.
llvm-svn: 71150
2009-05-07 05:42:24 +00:00