From 798b4afd48ebc0acc165789ab913ccd28466ef68 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Tue, 25 Sep 2007 17:55:50 +0000 Subject: [PATCH] Do not reserve DOM check for GetElementPtrInst. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42306 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/LICM.cpp | 43 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp index f112ba82620..e461c887ea2 100644 --- a/lib/Transforms/Scalar/LICM.cpp +++ b/lib/Transforms/Scalar/LICM.cpp @@ -811,30 +811,31 @@ void LICM::FindPromotableValuesInLoop( // condition which may not yet folded. if (isa(GEP->getOperand(0))) PointerOk = false; + } - // If GEP is use is not dominating loop exit then promoting - // GEP may expose unsafe load and store instructions unconditinally. - if (PointerOk) - for(Value::use_iterator UI = V->use_begin(), UE = V->use_end(); - UI != UE && PointerOk; ++UI) { - Instruction *Use = dyn_cast(*UI); - if (!Use) - continue; - for (SmallVector::iterator - ExitI = LoopExits.begin(), ExitE = LoopExits.end(); - ExitI != ExitE; ++ExitI) { - Instruction *Ex = *ExitI; - if (!DT->dominates(Use, Ex)){ - PointerOk = false; - break; - } - } - - if (!PointerOk) + // If value V use is not dominating loop exit then promoting + // it may expose unsafe load and store instructions unconditinally. + if (PointerOk) + for(Value::use_iterator UI = V->use_begin(), UE = V->use_end(); + UI != UE && PointerOk; ++UI) { + Instruction *Use = dyn_cast(*UI); + if (!Use || !CurLoop->contains(Use->getParent())) + continue; + for (SmallVector::iterator + ExitI = LoopExits.begin(), ExitE = LoopExits.end(); + ExitI != ExitE; ++ExitI) { + Instruction *Ex = *ExitI; + if (!DT->dominates(Use, Ex)){ + PointerOk = false; break; + } } - } - + + if (!PointerOk) + break; + } + + if (PointerOk) { const Type *Ty = cast(V->getType())->getElementType(); AllocaInst *AI = new AllocaInst(Ty, 0, V->getName()+".tmp", FnStart); -- 2.11.0