forked from OSchip/llvm-project
Plumb TLI through isSafeToExecuteUnconditionally [NFC]
Split from D95815 to reduce patch size. Isn't (yet) used for anything, only the client side is wired up.
This commit is contained in:
parent
7ad55a3df5
commit
9a82f42d12
|
@ -461,7 +461,8 @@ constexpr unsigned MaxAnalysisRecursionDepth = 6;
|
||||||
/// for such instructions, moving them may change the resulting value.
|
/// for such instructions, moving them may change the resulting value.
|
||||||
bool isSafeToSpeculativelyExecute(const Value *V,
|
bool isSafeToSpeculativelyExecute(const Value *V,
|
||||||
const Instruction *CtxI = nullptr,
|
const Instruction *CtxI = nullptr,
|
||||||
const DominatorTree *DT = nullptr);
|
const DominatorTree *DT = nullptr,
|
||||||
|
const TargetLibraryInfo *TLI = nullptr);
|
||||||
|
|
||||||
/// Returns true if the result or effects of the given instructions \p I
|
/// Returns true if the result or effects of the given instructions \p I
|
||||||
/// depend on or influence global memory.
|
/// depend on or influence global memory.
|
||||||
|
|
|
@ -4411,7 +4411,8 @@ bool llvm::mustSuppressSpeculation(const LoadInst &LI) {
|
||||||
|
|
||||||
bool llvm::isSafeToSpeculativelyExecute(const Value *V,
|
bool llvm::isSafeToSpeculativelyExecute(const Value *V,
|
||||||
const Instruction *CtxI,
|
const Instruction *CtxI,
|
||||||
const DominatorTree *DT) {
|
const DominatorTree *DT,
|
||||||
|
const TargetLibraryInfo *TLI) {
|
||||||
const Operator *Inst = dyn_cast<Operator>(V);
|
const Operator *Inst = dyn_cast<Operator>(V);
|
||||||
if (!Inst)
|
if (!Inst)
|
||||||
return false;
|
return false;
|
||||||
|
@ -4458,7 +4459,7 @@ bool llvm::isSafeToSpeculativelyExecute(const Value *V,
|
||||||
const DataLayout &DL = LI->getModule()->getDataLayout();
|
const DataLayout &DL = LI->getModule()->getDataLayout();
|
||||||
return isDereferenceableAndAlignedPointer(
|
return isDereferenceableAndAlignedPointer(
|
||||||
LI->getPointerOperand(), LI->getType(), MaybeAlign(LI->getAlignment()),
|
LI->getPointerOperand(), LI->getType(), MaybeAlign(LI->getAlignment()),
|
||||||
DL, CtxI, DT);
|
DL, CtxI, DT, TLI);
|
||||||
}
|
}
|
||||||
case Instruction::Call: {
|
case Instruction::Call: {
|
||||||
auto *CI = cast<const CallInst>(Inst);
|
auto *CI = cast<const CallInst>(Inst);
|
||||||
|
|
|
@ -162,6 +162,7 @@ static bool sink(Instruction &I, LoopInfo *LI, DominatorTree *DT,
|
||||||
OptimizationRemarkEmitter *ORE);
|
OptimizationRemarkEmitter *ORE);
|
||||||
static bool isSafeToExecuteUnconditionally(Instruction &Inst,
|
static bool isSafeToExecuteUnconditionally(Instruction &Inst,
|
||||||
const DominatorTree *DT,
|
const DominatorTree *DT,
|
||||||
|
const TargetLibraryInfo *TLI,
|
||||||
const Loop *CurLoop,
|
const Loop *CurLoop,
|
||||||
const LoopSafetyInfo *SafetyInfo,
|
const LoopSafetyInfo *SafetyInfo,
|
||||||
OptimizationRemarkEmitter *ORE,
|
OptimizationRemarkEmitter *ORE,
|
||||||
|
@ -921,7 +922,7 @@ bool llvm::hoistRegion(DomTreeNode *N, AAResults *AA, LoopInfo *LI,
|
||||||
ORE) &&
|
ORE) &&
|
||||||
worthSinkOrHoistInst(I, CurLoop->getLoopPreheader(), ORE, BFI) &&
|
worthSinkOrHoistInst(I, CurLoop->getLoopPreheader(), ORE, BFI) &&
|
||||||
isSafeToExecuteUnconditionally(
|
isSafeToExecuteUnconditionally(
|
||||||
I, DT, CurLoop, SafetyInfo, ORE,
|
I, DT, TLI, CurLoop, SafetyInfo, ORE,
|
||||||
CurLoop->getLoopPreheader()->getTerminator())) {
|
CurLoop->getLoopPreheader()->getTerminator())) {
|
||||||
hoist(I, DT, CurLoop, CFH.getOrCreateHoistedBlock(BB), SafetyInfo,
|
hoist(I, DT, CurLoop, CFH.getOrCreateHoistedBlock(BB), SafetyInfo,
|
||||||
MSSAU, SE, ORE);
|
MSSAU, SE, ORE);
|
||||||
|
@ -1815,11 +1816,12 @@ static void hoist(Instruction &I, const DominatorTree *DT, const Loop *CurLoop,
|
||||||
/// or if it is a trapping instruction and is guaranteed to execute.
|
/// or if it is a trapping instruction and is guaranteed to execute.
|
||||||
static bool isSafeToExecuteUnconditionally(Instruction &Inst,
|
static bool isSafeToExecuteUnconditionally(Instruction &Inst,
|
||||||
const DominatorTree *DT,
|
const DominatorTree *DT,
|
||||||
|
const TargetLibraryInfo *TLI,
|
||||||
const Loop *CurLoop,
|
const Loop *CurLoop,
|
||||||
const LoopSafetyInfo *SafetyInfo,
|
const LoopSafetyInfo *SafetyInfo,
|
||||||
OptimizationRemarkEmitter *ORE,
|
OptimizationRemarkEmitter *ORE,
|
||||||
const Instruction *CtxI) {
|
const Instruction *CtxI) {
|
||||||
if (isSafeToSpeculativelyExecute(&Inst, CtxI, DT))
|
if (isSafeToSpeculativelyExecute(&Inst, CtxI, DT, TLI))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
bool GuaranteedToExecute =
|
bool GuaranteedToExecute =
|
||||||
|
@ -2093,8 +2095,9 @@ bool llvm::promoteLoopAccessesToScalars(
|
||||||
// to execute does as well. Thus we can increase our guaranteed
|
// to execute does as well. Thus we can increase our guaranteed
|
||||||
// alignment as well.
|
// alignment as well.
|
||||||
if (!DereferenceableInPH || (InstAlignment > Alignment))
|
if (!DereferenceableInPH || (InstAlignment > Alignment))
|
||||||
if (isSafeToExecuteUnconditionally(*Load, DT, CurLoop, SafetyInfo,
|
if (isSafeToExecuteUnconditionally(*Load, DT, TLI, CurLoop,
|
||||||
ORE, Preheader->getTerminator())) {
|
SafetyInfo, ORE,
|
||||||
|
Preheader->getTerminator())) {
|
||||||
DereferenceableInPH = true;
|
DereferenceableInPH = true;
|
||||||
Alignment = std::max(Alignment, InstAlignment);
|
Alignment = std::max(Alignment, InstAlignment);
|
||||||
}
|
}
|
||||||
|
@ -2141,7 +2144,7 @@ bool llvm::promoteLoopAccessesToScalars(
|
||||||
if (!DereferenceableInPH) {
|
if (!DereferenceableInPH) {
|
||||||
DereferenceableInPH = isDereferenceableAndAlignedPointer(
|
DereferenceableInPH = isDereferenceableAndAlignedPointer(
|
||||||
Store->getPointerOperand(), Store->getValueOperand()->getType(),
|
Store->getPointerOperand(), Store->getValueOperand()->getType(),
|
||||||
Store->getAlign(), MDL, Preheader->getTerminator(), DT);
|
Store->getAlign(), MDL, Preheader->getTerminator(), DT, TLI);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
return false; // Not a load or store.
|
return false; // Not a load or store.
|
||||||
|
|
Loading…
Reference in New Issue