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

llvm-svn: 18363
This commit is contained in:
Chris Lattner 2004-11-29 21:26:12 +00:00
parent 0ea40c935f
commit 6e455608e2
1 changed files with 6 additions and 0 deletions

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);