forked from OSchip/llvm-project
				
			Take advantage of the new fast SmallPtrSet assignment operator when propagating AVAIL_OUT sets.
This reduces the time to optimize Anton's testcase from 31.2s to 21.s! llvm-svn: 38475
This commit is contained in:
		
							parent
							
								
									e33356b18e
								
							
						
					
					
						commit
						effc7a7d16
					
				| 
						 | 
					@ -574,7 +574,8 @@ class ValueNumberedSet {
 | 
				
			||||||
      numbers.set(i);
 | 
					      numbers.set(i);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    void copyNumbers(ValueNumberedSet& other) {
 | 
					    void operator=(const ValueNumberedSet& other) {
 | 
				
			||||||
 | 
					      contents = other.contents;
 | 
				
			||||||
      numbers = other.numbers;
 | 
					      numbers = other.numbers;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
| 
						 | 
					@ -710,11 +711,10 @@ void GVNPRE::val_insert(ValueNumberedSet& s, Value* v) {
 | 
				
			||||||
void GVNPRE::val_replace(ValueNumberedSet& s, Value* v) {
 | 
					void GVNPRE::val_replace(ValueNumberedSet& s, Value* v) {
 | 
				
			||||||
  uint32_t num = VN.lookup(v);
 | 
					  uint32_t num = VN.lookup(v);
 | 
				
			||||||
  Value* leader = find_leader(s, num);
 | 
					  Value* leader = find_leader(s, num);
 | 
				
			||||||
  while (leader != 0) {
 | 
					  if (leader != 0)
 | 
				
			||||||
    s.erase(leader);
 | 
					    s.erase(leader);
 | 
				
			||||||
    leader = find_leader(s, num);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  s.insert(v);
 | 
					  s.insert(v);
 | 
				
			||||||
 | 
					  s.set(num);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// phi_translate - Given a value, its parent block, and a predecessor of its
 | 
					/// phi_translate - Given a value, its parent block, and a predecessor of its
 | 
				
			||||||
| 
						 | 
					@ -1154,8 +1154,6 @@ void GVNPRE::dump(ValueNumberedSet& s) const {
 | 
				
			||||||
/// elimination by walking the dominator tree and removing any instruction that 
 | 
					/// elimination by walking the dominator tree and removing any instruction that 
 | 
				
			||||||
/// is dominated by another instruction with the same value number.
 | 
					/// is dominated by another instruction with the same value number.
 | 
				
			||||||
bool GVNPRE::elimination() {
 | 
					bool GVNPRE::elimination() {
 | 
				
			||||||
  DOUT << "\n\nPhase 3: Elimination\n\n";
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  bool changed_function = false;
 | 
					  bool changed_function = false;
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  std::vector<std::pair<Instruction*, Value*> > replace;
 | 
					  std::vector<std::pair<Instruction*, Value*> > replace;
 | 
				
			||||||
| 
						 | 
					@ -1167,10 +1165,6 @@ bool GVNPRE::elimination() {
 | 
				
			||||||
         E = df_end(DT.getRootNode()); DI != E; ++DI) {
 | 
					         E = df_end(DT.getRootNode()); DI != E; ++DI) {
 | 
				
			||||||
    BasicBlock* BB = DI->getBlock();
 | 
					    BasicBlock* BB = DI->getBlock();
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    //DOUT << "Block: " << BB->getName() << "\n";
 | 
					 | 
				
			||||||
    //dump(availableOut[BB]);
 | 
					 | 
				
			||||||
    //DOUT << "\n\n";
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    for (BasicBlock::iterator BI = BB->begin(), BE = BB->end();
 | 
					    for (BasicBlock::iterator BI = BB->begin(), BE = BB->end();
 | 
				
			||||||
         BI != BE; ++BI) {
 | 
					         BI != BE; ++BI) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1354,7 +1348,6 @@ bool GVNPRE::buildsets_anticout(BasicBlock* BB,
 | 
				
			||||||
  if (BB->getTerminator()->getNumSuccessors() == 1) {
 | 
					  if (BB->getTerminator()->getNumSuccessors() == 1) {
 | 
				
			||||||
    if (BB->getTerminator()->getSuccessor(0) != BB &&
 | 
					    if (BB->getTerminator()->getSuccessor(0) != BB &&
 | 
				
			||||||
        visited.count(BB->getTerminator()->getSuccessor(0)) == 0) {
 | 
					        visited.count(BB->getTerminator()->getSuccessor(0)) == 0) {
 | 
				
			||||||
          DOUT << "DEFER: " << BB->getName() << "\n";
 | 
					 | 
				
			||||||
      return true;
 | 
					      return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else {
 | 
					    else {
 | 
				
			||||||
| 
						 | 
					@ -1459,12 +1452,8 @@ void GVNPRE::buildsets(Function& F) {
 | 
				
			||||||
    BasicBlock* BB = DI->getBlock();
 | 
					    BasicBlock* BB = DI->getBlock();
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
    // A block inherits AVAIL_OUT from its dominator
 | 
					    // A block inherits AVAIL_OUT from its dominator
 | 
				
			||||||
    if (DI->getIDom() != 0) {
 | 
					    if (DI->getIDom() != 0)
 | 
				
			||||||
      currAvail.insert(availableOut[DI->getIDom()->getBlock()].begin(),
 | 
					      currAvail = availableOut[DI->getIDom()->getBlock()];
 | 
				
			||||||
                       availableOut[DI->getIDom()->getBlock()].end());
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
      currAvail.copyNumbers(availableOut[DI->getIDom()->getBlock()]);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (BasicBlock::iterator BI = BB->begin(), BE = BB->end();
 | 
					    for (BasicBlock::iterator BI = BB->begin(), BE = BB->end();
 | 
				
			||||||
         BI != BE; ++BI)
 | 
					         BI != BE; ++BI)
 | 
				
			||||||
| 
						 | 
					@ -1517,8 +1506,6 @@ void GVNPRE::buildsets(Function& F) {
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    iterations++;
 | 
					    iterations++;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  DOUT << "ITERATIONS: " << iterations << "\n";
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// insertion_pre - When a partial redundancy has been identified, eliminate it
 | 
					/// insertion_pre - When a partial redundancy has been identified, eliminate it
 | 
				
			||||||
| 
						 | 
					@ -1528,7 +1515,6 @@ void GVNPRE::insertion_pre(Value* e, BasicBlock* BB,
 | 
				
			||||||
                           std::map<BasicBlock*, Value*>& avail,
 | 
					                           std::map<BasicBlock*, Value*>& avail,
 | 
				
			||||||
                    std::map<BasicBlock*, ValueNumberedSet>& new_sets) {
 | 
					                    std::map<BasicBlock*, ValueNumberedSet>& new_sets) {
 | 
				
			||||||
  for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB); PI != PE; ++PI) {
 | 
					  for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB); PI != PE; ++PI) {
 | 
				
			||||||
    DOUT << "PRED: " << (*PI)->getName() << "\n";
 | 
					 | 
				
			||||||
    Value* e2 = avail[*PI];
 | 
					    Value* e2 = avail[*PI];
 | 
				
			||||||
    if (!availableOut[*PI].test(VN.lookup(e2))) {
 | 
					    if (!availableOut[*PI].test(VN.lookup(e2))) {
 | 
				
			||||||
      User* U = cast<User>(e2);
 | 
					      User* U = cast<User>(e2);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue