mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-11-04 05:17:07 +00:00 
			
		
		
		
	Move trip count discovery outside of the generic LoopUnroll helper. This
removes its dependence on canonical induction variables. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135829 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		@@ -22,7 +22,8 @@ class Loop;
 | 
				
			|||||||
class LoopInfo;
 | 
					class LoopInfo;
 | 
				
			||||||
class LPPassManager;
 | 
					class LPPassManager;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool UnrollLoop(Loop *L, unsigned Count, LoopInfo* LI, LPPassManager* LPM);
 | 
					bool UnrollLoop(Loop *L, unsigned Count, unsigned TripCount,
 | 
				
			||||||
 | 
					                unsigned TripMultiple, LoopInfo* LI, LPPassManager* LPM);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -137,9 +137,14 @@ bool LoopUnroll::runOnLoop(Loop *L, LPPassManager &LPM) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  // Find trip count
 | 
					  // Find trip count
 | 
				
			||||||
  unsigned TripCount = L->getSmallConstantTripCount();
 | 
					  unsigned TripCount = L->getSmallConstantTripCount();
 | 
				
			||||||
  unsigned Count = CurrentCount;
 | 
					
 | 
				
			||||||
 | 
					  // Find trip multiple if count is not available
 | 
				
			||||||
 | 
					  unsigned TripMultiple = 1;
 | 
				
			||||||
 | 
					  if (TripCount == 0)
 | 
				
			||||||
 | 
					    TripMultiple = L->getSmallConstantTripMultiple();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Automatically select an unroll count.
 | 
					  // Automatically select an unroll count.
 | 
				
			||||||
 | 
					  unsigned Count = CurrentCount;
 | 
				
			||||||
  if (Count == 0) {
 | 
					  if (Count == 0) {
 | 
				
			||||||
    // Conservative heuristic: if we know the trip count, see if we can
 | 
					    // Conservative heuristic: if we know the trip count, see if we can
 | 
				
			||||||
    // completely unroll (subject to the threshold, checked below); otherwise
 | 
					    // completely unroll (subject to the threshold, checked below); otherwise
 | 
				
			||||||
@@ -183,7 +188,7 @@ bool LoopUnroll::runOnLoop(Loop *L, LPPassManager &LPM) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  // Unroll the loop.
 | 
					  // Unroll the loop.
 | 
				
			||||||
  Function *F = L->getHeader()->getParent();
 | 
					  Function *F = L->getHeader()->getParent();
 | 
				
			||||||
  if (!UnrollLoop(L, Count, LI, &LPM))
 | 
					  if (!UnrollLoop(L, Count, TripCount, TripMultiple, LI, &LPM))
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // FIXME: Reconstruct dom info, because it is not preserved properly.
 | 
					  // FIXME: Reconstruct dom info, because it is not preserved properly.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,9 +11,6 @@
 | 
				
			|||||||
// actual pass or policy, but provides a single function to perform loop
 | 
					// actual pass or policy, but provides a single function to perform loop
 | 
				
			||||||
// unrolling.
 | 
					// unrolling.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// It works best when loops have been canonicalized by the -indvars pass,
 | 
					 | 
				
			||||||
// allowing it to determine the trip counts of loops easily.
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// The process of unrolling can produce extraneous basic blocks linked with
 | 
					// The process of unrolling can produce extraneous basic blocks linked with
 | 
				
			||||||
// unconditional branches.  This will be corrected in the future.
 | 
					// unconditional branches.  This will be corrected in the future.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
@@ -113,8 +110,8 @@ static BasicBlock *FoldBlockIntoPredecessor(BasicBlock *BB, LoopInfo* LI) {
 | 
				
			|||||||
///
 | 
					///
 | 
				
			||||||
/// If a LoopPassManager is passed in, and the loop is fully removed, it will be
 | 
					/// If a LoopPassManager is passed in, and the loop is fully removed, it will be
 | 
				
			||||||
/// removed from the LoopPassManager as well. LPM can also be NULL.
 | 
					/// removed from the LoopPassManager as well. LPM can also be NULL.
 | 
				
			||||||
bool llvm::UnrollLoop(Loop *L, unsigned Count,
 | 
					bool llvm::UnrollLoop(Loop *L, unsigned Count, unsigned TripCount,
 | 
				
			||||||
                      LoopInfo *LI, LPPassManager *LPM) {
 | 
					                      unsigned TripMultiple, LoopInfo *LI, LPPassManager *LPM) {
 | 
				
			||||||
  BasicBlock *Preheader = L->getLoopPreheader();
 | 
					  BasicBlock *Preheader = L->getLoopPreheader();
 | 
				
			||||||
  if (!Preheader) {
 | 
					  if (!Preheader) {
 | 
				
			||||||
    DEBUG(dbgs() << "  Can't unroll; loop preheader-insertion failed.\n");
 | 
					    DEBUG(dbgs() << "  Can't unroll; loop preheader-insertion failed.\n");
 | 
				
			||||||
@@ -149,13 +146,6 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count,
 | 
				
			|||||||
  if (ScalarEvolution *SE = LPM->getAnalysisIfAvailable<ScalarEvolution>())
 | 
					  if (ScalarEvolution *SE = LPM->getAnalysisIfAvailable<ScalarEvolution>())
 | 
				
			||||||
    SE->forgetLoop(L);
 | 
					    SE->forgetLoop(L);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Find trip count
 | 
					 | 
				
			||||||
  unsigned TripCount = L->getSmallConstantTripCount();
 | 
					 | 
				
			||||||
  // Find trip multiple if count is not available
 | 
					 | 
				
			||||||
  unsigned TripMultiple = 1;
 | 
					 | 
				
			||||||
  if (TripCount == 0)
 | 
					 | 
				
			||||||
    TripMultiple = L->getSmallConstantTripMultiple();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (TripCount != 0)
 | 
					  if (TripCount != 0)
 | 
				
			||||||
    DEBUG(dbgs() << "  Trip Count = " << TripCount << "\n");
 | 
					    DEBUG(dbgs() << "  Trip Count = " << TripCount << "\n");
 | 
				
			||||||
  if (TripMultiple != 1)
 | 
					  if (TripMultiple != 1)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user