Allow hoisting loads of globals and alloca's in conditionals.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18363 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2004-11-29 21:26:12 +00:00
parent 478b3b42e2
commit 8a9193927a

View File

@ -592,6 +592,12 @@ bool LICM::isSafeToExecuteUnconditionally(Instruction &Inst) {
if (Inst.getParent() == CurLoop->getHeader())
return true;
// It's always safe to load from a global or alloca.
if (isa<LoadInst>(Inst))
if (isa<AllocationInst>(Inst.getOperand(0)) ||
isa<GlobalVariable>(Inst.getOperand(0)))
return true;
// Get the exit blocks for the current loop.
std::vector<BasicBlock*> ExitBlocks;
CurLoop->getExitBlocks(ExitBlocks);