mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-11-04 05:17:07 +00:00 
			
		
		
		
	Simplify LoopStrengthReduce::DeleteTriviallyDeadInstructions by
making it use RecursivelyDeleteTriviallyDeadInstructions to do the heavy lifting. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60195 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		@@ -240,31 +240,30 @@ Value *LoopStrengthReduce::getCastedVersionOf(Instruction::CastOps opcode,
 | 
				
			|||||||
/// their operands subsequently dead.
 | 
					/// their operands subsequently dead.
 | 
				
			||||||
void LoopStrengthReduce::
 | 
					void LoopStrengthReduce::
 | 
				
			||||||
DeleteTriviallyDeadInstructions(SetVector<Instruction*> &Insts) {
 | 
					DeleteTriviallyDeadInstructions(SetVector<Instruction*> &Insts) {
 | 
				
			||||||
 | 
					  SmallVector<Instruction*, 16> DeadInsts;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
  while (!Insts.empty()) {
 | 
					  while (!Insts.empty()) {
 | 
				
			||||||
    Instruction *I = Insts.back();
 | 
					    Instruction *I = Insts.back();
 | 
				
			||||||
    Insts.pop_back();
 | 
					    Insts.pop_back();
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    if (PHINode *PN = dyn_cast<PHINode>(I)) {
 | 
					    // If I is dead, delete it and all the things that it recursively uses
 | 
				
			||||||
      // If all incoming values to the Phi are the same, we can replace the Phi
 | 
					    // that become dead.
 | 
				
			||||||
      // with that value.
 | 
					    RecursivelyDeleteTriviallyDeadInstructions(I, &DeadInsts);
 | 
				
			||||||
      if (Value *PNV = PN->hasConstantValue()) {
 | 
					 | 
				
			||||||
        if (Instruction *U = dyn_cast<Instruction>(PNV))
 | 
					 | 
				
			||||||
          Insts.insert(U);
 | 
					 | 
				
			||||||
        SE->deleteValueFromRecords(PN);
 | 
					 | 
				
			||||||
        PN->replaceAllUsesWith(PNV);
 | 
					 | 
				
			||||||
        PN->eraseFromParent();
 | 
					 | 
				
			||||||
        Changed = true;
 | 
					 | 
				
			||||||
        continue;
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    if (isInstructionTriviallyDead(I)) {
 | 
					    if (DeadInsts.empty()) continue;
 | 
				
			||||||
      for (User::op_iterator i = I->op_begin(), e = I->op_end(); i != e; ++i)
 | 
					    Changed = true;
 | 
				
			||||||
        if (Instruction *U = dyn_cast<Instruction>(*i))
 | 
					
 | 
				
			||||||
          Insts.insert(U);
 | 
					    while (!DeadInsts.empty()) {
 | 
				
			||||||
      SE->deleteValueFromRecords(I);
 | 
					      Instruction *DeadInst = DeadInsts.back();
 | 
				
			||||||
      I->eraseFromParent();
 | 
					      DeadInsts.pop_back();
 | 
				
			||||||
      Changed = true;
 | 
					      
 | 
				
			||||||
 | 
					      // Make sure ScalarEvolutions knows this instruction is gone.
 | 
				
			||||||
 | 
					      SE->deleteValueFromRecords(DeadInst);
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      // Make sure that this instruction is removed from DeadInsts if it was
 | 
				
			||||||
 | 
					      // recursively removed.
 | 
				
			||||||
 | 
					      if (DeadInst != I)
 | 
				
			||||||
 | 
					        Insts.remove(DeadInst);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user