[llvm] 9a82f42 - Plumb TLI through isSafeToExecuteUnconditionally [NFC]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 24 17:52:14 PDT 2021
Author: Philip Reames
Date: 2021-03-24T17:52:04-07:00
New Revision: 9a82f42d12f85386b9e654f2c01cf0bf493482e6
URL: https://github.com/llvm/llvm-project/commit/9a82f42d12f85386b9e654f2c01cf0bf493482e6
DIFF: https://github.com/llvm/llvm-project/commit/9a82f42d12f85386b9e654f2c01cf0bf493482e6.diff
LOG: 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.
Added:
Modified:
llvm/include/llvm/Analysis/ValueTracking.h
llvm/lib/Analysis/ValueTracking.cpp
llvm/lib/Transforms/Scalar/LICM.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h
index efea370bc803..90ec742f18e6 100644
--- a/llvm/include/llvm/Analysis/ValueTracking.h
+++ b/llvm/include/llvm/Analysis/ValueTracking.h
@@ -461,7 +461,8 @@ constexpr unsigned MaxAnalysisRecursionDepth = 6;
/// for such instructions, moving them may change the resulting value.
bool isSafeToSpeculativelyExecute(const Value *V,
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
/// depend on or influence global memory.
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index cd08c4e09a45..7b43ce0f95e1 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -4411,7 +4411,8 @@ bool llvm::mustSuppressSpeculation(const LoadInst &LI) {
bool llvm::isSafeToSpeculativelyExecute(const Value *V,
const Instruction *CtxI,
- const DominatorTree *DT) {
+ const DominatorTree *DT,
+ const TargetLibraryInfo *TLI) {
const Operator *Inst = dyn_cast<Operator>(V);
if (!Inst)
return false;
@@ -4458,7 +4459,7 @@ bool llvm::isSafeToSpeculativelyExecute(const Value *V,
const DataLayout &DL = LI->getModule()->getDataLayout();
return isDereferenceableAndAlignedPointer(
LI->getPointerOperand(), LI->getType(), MaybeAlign(LI->getAlignment()),
- DL, CtxI, DT);
+ DL, CtxI, DT, TLI);
}
case Instruction::Call: {
auto *CI = cast<const CallInst>(Inst);
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index 10426e600fca..587b58ff5622 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -162,6 +162,7 @@ static bool sink(Instruction &I, LoopInfo *LI, DominatorTree *DT,
OptimizationRemarkEmitter *ORE);
static bool isSafeToExecuteUnconditionally(Instruction &Inst,
const DominatorTree *DT,
+ const TargetLibraryInfo *TLI,
const Loop *CurLoop,
const LoopSafetyInfo *SafetyInfo,
OptimizationRemarkEmitter *ORE,
@@ -921,7 +922,7 @@ bool llvm::hoistRegion(DomTreeNode *N, AAResults *AA, LoopInfo *LI,
ORE) &&
worthSinkOrHoistInst(I, CurLoop->getLoopPreheader(), ORE, BFI) &&
isSafeToExecuteUnconditionally(
- I, DT, CurLoop, SafetyInfo, ORE,
+ I, DT, TLI, CurLoop, SafetyInfo, ORE,
CurLoop->getLoopPreheader()->getTerminator())) {
hoist(I, DT, CurLoop, CFH.getOrCreateHoistedBlock(BB), SafetyInfo,
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.
static bool isSafeToExecuteUnconditionally(Instruction &Inst,
const DominatorTree *DT,
+ const TargetLibraryInfo *TLI,
const Loop *CurLoop,
const LoopSafetyInfo *SafetyInfo,
OptimizationRemarkEmitter *ORE,
const Instruction *CtxI) {
- if (isSafeToSpeculativelyExecute(&Inst, CtxI, DT))
+ if (isSafeToSpeculativelyExecute(&Inst, CtxI, DT, TLI))
return true;
bool GuaranteedToExecute =
@@ -2093,8 +2095,9 @@ bool llvm::promoteLoopAccessesToScalars(
// to execute does as well. Thus we can increase our guaranteed
// alignment as well.
if (!DereferenceableInPH || (InstAlignment > Alignment))
- if (isSafeToExecuteUnconditionally(*Load, DT, CurLoop, SafetyInfo,
- ORE, Preheader->getTerminator())) {
+ if (isSafeToExecuteUnconditionally(*Load, DT, TLI, CurLoop,
+ SafetyInfo, ORE,
+ Preheader->getTerminator())) {
DereferenceableInPH = true;
Alignment = std::max(Alignment, InstAlignment);
}
@@ -2141,7 +2144,7 @@ bool llvm::promoteLoopAccessesToScalars(
if (!DereferenceableInPH) {
DereferenceableInPH = isDereferenceableAndAlignedPointer(
Store->getPointerOperand(), Store->getValueOperand()->getType(),
- Store->getAlign(), MDL, Preheader->getTerminator(), DT);
+ Store->getAlign(), MDL, Preheader->getTerminator(), DT, TLI);
}
} else
return false; // Not a load or store.
More information about the llvm-commits
mailing list