From 8a9193927a2661293a2afd5d1420faa2b0b8e6bf Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 29 Nov 2004 21:26:12 +0000 Subject: [PATCH] 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 --- lib/Transforms/Scalar/LICM.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp index e9f2b330eef..c20e179f107 100644 --- a/lib/Transforms/Scalar/LICM.cpp +++ b/lib/Transforms/Scalar/LICM.cpp @@ -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(Inst)) + if (isa(Inst.getOperand(0)) || + isa(Inst.getOperand(0))) + return true; + // Get the exit blocks for the current loop. std::vector ExitBlocks; CurLoop->getExitBlocks(ExitBlocks);