Skip to content

Commit e81d50b

Browse files
committedSep 1, 2016
Refactor LICM to expose canSinkOrHoistInst to LoopSink pass.
Summary: LoopSink pass shares the same canSinkOrHoistInst functionality with LICM pass. This patch exposes this function in preparation of https://reviews.llvm.org/D22778 Reviewers: chandlerc, davidxl, danielcdh Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D24171 llvm-svn: 280429
1 parent e091f8e commit e81d50b

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed
 

‎llvm/include/llvm/Transforms/Utils/LoopUtils.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
#include "llvm/IR/IRBuilder.h"
2222

2323
namespace llvm {
24+
class AAResults;
2425
class AliasSet;
2526
class AliasSetTracker;
2627
class AssumptionCache;
2728
class BasicBlock;
2829
class DataLayout;
2930
class DominatorTree;
31+
class Instruction;
3032
class Loop;
3133
class LoopInfo;
3234
class Pass;
@@ -467,6 +469,12 @@ void addStringMetadataToLoop(Loop *TheLoop, const char *MDString,
467469
/// All loop passes should call this as part of implementing their \c
468470
/// getAnalysisUsage.
469471
void getLoopAnalysisUsage(AnalysisUsage &AU);
470-
}
471472

473+
/// canSinkOrHoistInst - Return true if the hoister and sinker can handle this
474+
/// instruction. If SafetyInfo is not nullptr, check if the instruction can
475+
/// execute speculatively.
476+
bool canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT,
477+
Loop *CurLoop, AliasSetTracker *CurAST,
478+
LoopSafetyInfo *SafetyInfo);
479+
}
472480
#endif

‎llvm/lib/Transforms/Scalar/LICM.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@ static Instruction *
100100
CloneInstructionInExitBlock(Instruction &I, BasicBlock &ExitBlock, PHINode &PN,
101101
const LoopInfo *LI,
102102
const LoopSafetyInfo *SafetyInfo);
103-
static bool canSinkOrHoistInst(Instruction &I, AliasAnalysis *AA,
104-
DominatorTree *DT,
105-
Loop *CurLoop, AliasSetTracker *CurAST,
106-
LoopSafetyInfo *SafetyInfo);
107103

108104
namespace {
109105
struct LoopInvariantCodeMotion {
@@ -439,9 +435,9 @@ void llvm::computeLoopSafetyInfo(LoopSafetyInfo *SafetyInfo, Loop *CurLoop) {
439435
/// canSinkOrHoistInst - Return true if the hoister and sinker can handle this
440436
/// instruction.
441437
///
442-
bool canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT,
443-
Loop *CurLoop, AliasSetTracker *CurAST,
444-
LoopSafetyInfo *SafetyInfo) {
438+
bool llvm::canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT,
439+
Loop *CurLoop, AliasSetTracker *CurAST,
440+
LoopSafetyInfo *SafetyInfo) {
445441
if (!isa<LoadInst>(I) && !isa<CallInst>(I) &&
446442
!isa<BinaryOperator>(I) && !isa<CastInst>(I) && !isa<SelectInst>(I) &&
447443
!isa<GetElementPtrInst>(I) && !isa<CmpInst>(I) &&

0 commit comments

Comments
 (0)
Please sign in to comment.