aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Analysis
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-01-06 20:13:21 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-01-06 20:13:21 +0000
commit7e7b6700743285c0af506ac6299ddf82ebd434b9 (patch)
tree578d2ea1868b77f3dff145df7f8f3fe73272c09e /include/llvm/Analysis
parent4b570baa7e867c652fa7d690585098278082fae9 (diff)
downloadsrc-7e7b6700743285c0af506ac6299ddf82ebd434b9.tar.gz
src-7e7b6700743285c0af506ac6299ddf82ebd434b9.zip
Vendor import of llvm trunk r291274:vendor/llvm/llvm-trunk-r291274
Notes
Notes: svn path=/vendor/llvm/dist/; revision=311532 svn path=/vendor/llvm/llvm-trunk-r291274/; revision=311533; tag=vendor/llvm/llvm-trunk-r291274
Diffstat (limited to 'include/llvm/Analysis')
-rw-r--r--include/llvm/Analysis/CGSCCPassManager.h2
-rw-r--r--include/llvm/Analysis/TargetTransformInfo.h19
-rw-r--r--include/llvm/Analysis/TargetTransformInfoImpl.h30
3 files changed, 42 insertions, 9 deletions
diff --git a/include/llvm/Analysis/CGSCCPassManager.h b/include/llvm/Analysis/CGSCCPassManager.h
index 54ef1a688d37..6fbe532112b2 100644
--- a/include/llvm/Analysis/CGSCCPassManager.h
+++ b/include/llvm/Analysis/CGSCCPassManager.h
@@ -128,7 +128,7 @@ extern template class PassManager<LazyCallGraph::SCC, CGSCCAnalysisManager,
/// \brief The CGSCC pass manager.
///
/// See the documentation for the PassManager template for details. It runs
-/// a sequency of SCC passes over each SCC that the manager is run over. This
+/// a sequence of SCC passes over each SCC that the manager is run over. This
/// typedef serves as a convenient way to refer to this construct.
typedef PassManager<LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &,
CGSCCUpdateResult &>
diff --git a/include/llvm/Analysis/TargetTransformInfo.h b/include/llvm/Analysis/TargetTransformInfo.h
index d583614284ff..b4a6c5c2fae0 100644
--- a/include/llvm/Analysis/TargetTransformInfo.h
+++ b/include/llvm/Analysis/TargetTransformInfo.h
@@ -36,6 +36,8 @@ namespace llvm {
class Function;
class GlobalValue;
class Loop;
+class ScalarEvolution;
+class SCEV;
class Type;
class User;
class Value;
@@ -613,10 +615,11 @@ public:
/// merged into the instruction indexing mode. Some targets might want to
/// distinguish between address computation for memory operations on vector
/// types and scalar types. Such targets should override this function.
- /// The 'IsComplex' parameter is a hint that the address computation is likely
- /// to involve multiple instructions and as such unlikely to be merged into
- /// the address indexing mode.
- int getAddressComputationCost(Type *Ty, bool IsComplex = false) const;
+ /// The 'SE' parameter holds pointer for the scalar evolution object which
+ /// is used in order to get the Ptr step value in case of constant stride.
+ /// The 'Ptr' parameter holds SCEV of the access pointer.
+ int getAddressComputationCost(Type *Ty, ScalarEvolution *SE = nullptr,
+ const SCEV *Ptr = nullptr) const;
/// \returns The cost, if any, of keeping values of the given types alive
/// over a callsite.
@@ -795,7 +798,8 @@ public:
virtual int getCallInstrCost(Function *F, Type *RetTy,
ArrayRef<Type *> Tys) = 0;
virtual unsigned getNumberOfParts(Type *Tp) = 0;
- virtual int getAddressComputationCost(Type *Ty, bool IsComplex) = 0;
+ virtual int getAddressComputationCost(Type *Ty, ScalarEvolution *SE,
+ const SCEV *Ptr) = 0;
virtual unsigned getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) = 0;
virtual bool getTgtMemIntrinsic(IntrinsicInst *Inst,
MemIntrinsicInfo &Info) = 0;
@@ -1044,8 +1048,9 @@ public:
unsigned getNumberOfParts(Type *Tp) override {
return Impl.getNumberOfParts(Tp);
}
- int getAddressComputationCost(Type *Ty, bool IsComplex) override {
- return Impl.getAddressComputationCost(Ty, IsComplex);
+ int getAddressComputationCost(Type *Ty, ScalarEvolution *SE,
+ const SCEV *Ptr) override {
+ return Impl.getAddressComputationCost(Ty, SE, Ptr);
}
unsigned getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) override {
return Impl.getCostOfKeepingLiveOverCall(Tys);
diff --git a/include/llvm/Analysis/TargetTransformInfoImpl.h b/include/llvm/Analysis/TargetTransformInfoImpl.h
index 68b38a7fa538..1d7edbaf7df0 100644
--- a/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -15,6 +15,7 @@
#ifndef LLVM_ANALYSIS_TARGETTRANSFORMINFOIMPL_H
#define LLVM_ANALYSIS_TARGETTRANSFORMINFOIMPL_H
+#include "llvm/Analysis/ScalarEvolutionExpressions.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/DataLayout.h"
@@ -370,7 +371,10 @@ public:
unsigned getNumberOfParts(Type *Tp) { return 0; }
- unsigned getAddressComputationCost(Type *Tp, bool) { return 0; }
+ unsigned getAddressComputationCost(Type *Tp, ScalarEvolution *,
+ const SCEV *) {
+ return 0;
+ }
unsigned getReductionCost(unsigned, Type *, bool) { return 1; }
@@ -422,6 +426,30 @@ public:
VectorType *VecTy) const {
return VF;
}
+protected:
+ bool isStridedAccess(const SCEV *Ptr) {
+ return Ptr && isa<SCEVAddRecExpr>(Ptr);
+ }
+
+ const SCEVConstant *getConstantStrideStep(ScalarEvolution *SE,
+ const SCEV *Ptr) {
+ if (!isStridedAccess(Ptr))
+ return nullptr;
+ const SCEVAddRecExpr *AddRec = cast<SCEVAddRecExpr>(Ptr);
+ return dyn_cast<SCEVConstant>(AddRec->getStepRecurrence(*SE));
+ }
+
+ bool isConstantStridedAccessLessThan(ScalarEvolution *SE, const SCEV *Ptr,
+ int64_t MergeDistance) {
+ const SCEVConstant *Step = getConstantStrideStep(SE, Ptr);
+ if (!Step)
+ return false;
+ APInt StrideVal = Step->getAPInt();
+ if (StrideVal.getBitWidth() > 64)
+ return false;
+ // FIXME: need to take absolute value for negtive stride case
+ return StrideVal.getSExtValue() < MergeDistance;
+ }
};
/// \brief CRTP base class for use as a mix-in that aids implementing