Changeset View
Changeset View
Standalone View
Standalone View
lib/Transforms/Scalar/JumpThreading.cpp
Context not available. | |||||
// If we're branching on a conditional, LVI might be able to determine | // If we're branching on a conditional, LVI might be able to determine | ||||
// it's value at the branch instruction. We only handle comparisons | // it's value at the branch instruction. We only handle comparisons | ||||
// against a constant at this time. | // against a constant at this time. | ||||
// TODO: This should be extended to handle switches as well. | // TODO: This should be extended to handle switches as well. | ||||
BranchInst *CondBr = dyn_cast<BranchInst>(BB->getTerminator()); | BranchInst *CondBr = dyn_cast<BranchInst>(BB->getTerminator()); | ||||
Constant *CondConst = dyn_cast<Constant>(CondCmp->getOperand(1)); | Constant *CondConst = dyn_cast<Constant>(CondCmp->getOperand(1)); | ||||
if (CondBr && CondConst && CondBr->isConditional()) { | if (CondBr && CondConst && CondBr->isConditional()) { | ||||
Context not available. | |||||
BasicBlock::iterator BBIt = LI; | BasicBlock::iterator BBIt = LI; | ||||
if (Value *AvailableVal = | if (Value *AvailableVal = | ||||
FindAvailableLoadedValue(LoadedPtr, LoadBB, BBIt, 6)) { | FindAvailableLoadedValue(LoadedPtr, LoadBB, BBIt)) { | ||||
// If the value if the load is locally available within the block, just use | // If the value if the load is locally available within the block, just use | ||||
// it. This frequently occurs for reg2mem'd allocas. | // it. This frequently occurs for reg2mem'd allocas. | ||||
//cerr << "LOAD ELIMINATED:\n" << *BBIt << *LI << "\n"; | //cerr << "LOAD ELIMINATED:\n" << *BBIt << *LI << "\n"; | ||||
Context not available. | |||||
// Scan the predecessor to see if the value is available in the pred. | // Scan the predecessor to see if the value is available in the pred. | ||||
BBIt = PredBB->end(); | BBIt = PredBB->end(); | ||||
AAMDNodes ThisAATags; | AAMDNodes ThisAATags; | ||||
Value *PredAvailable = FindAvailableLoadedValue(LoadedPtr, PredBB, BBIt, 6, | Value *PredAvailable = FindAvailableLoadedValue(LoadedPtr, PredBB, BBIt, | ||||
DEF_MAX_INSTS_TO_SCAN, | |||||
nullptr, &ThisAATags); | nullptr, &ThisAATags); | ||||
if (!PredAvailable) { | if (!PredAvailable) { | ||||
OneUnavailablePred = PredBB; | OneUnavailablePred = PredBB; | ||||
Context not available. |