forked from OSchip/llvm-project
parent
ec8a217729
commit
f560b3d2db
|
@ -1862,7 +1862,7 @@ public:
|
||||||
inline const ParamVecType &getParams() const { return Parameters; }
|
inline const ParamVecType &getParams() const { return Parameters; }
|
||||||
|
|
||||||
/// @brief Take a list of parameters and add the new ones to the scop.
|
/// @brief Take a list of parameters and add the new ones to the scop.
|
||||||
void addParams(std::vector<const SCEV *> NewParameters);
|
void addParams(const ParameterSetTy &NewParameters);
|
||||||
|
|
||||||
int getNumArrays() { return ScopArrayInfoMap.size(); }
|
int getNumArrays() { return ScopArrayInfoMap.size(); }
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
#include "polly/Support/ScopHelper.h"
|
#include "polly/Support/ScopHelper.h"
|
||||||
#include "llvm/ADT/SetVector.h"
|
#include "llvm/ADT/SetVector.h"
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class Region;
|
class Region;
|
||||||
|
@ -60,12 +59,11 @@ bool isAffineExpr(const llvm::Region *R, llvm::Loop *Scope,
|
||||||
/// @brief Check if @p V describes an affine parameter constraint in @p R.
|
/// @brief Check if @p V describes an affine parameter constraint in @p R.
|
||||||
bool isAffineParamConstraint(llvm::Value *V, const llvm::Region *R,
|
bool isAffineParamConstraint(llvm::Value *V, const llvm::Region *R,
|
||||||
llvm::Loop *Scope, llvm::ScalarEvolution &SE,
|
llvm::Loop *Scope, llvm::ScalarEvolution &SE,
|
||||||
std::vector<const llvm::SCEV *> &Params,
|
ParameterSetTy &Params, bool OrExpr = false);
|
||||||
bool OrExpr = false);
|
|
||||||
|
|
||||||
std::vector<const llvm::SCEV *>
|
ParameterSetTy getParamsInAffineExpr(const llvm::Region *R, llvm::Loop *Scope,
|
||||||
getParamsInAffineExpr(const llvm::Region *R, llvm::Loop *Scope,
|
const llvm::SCEV *Expression,
|
||||||
const llvm::SCEV *Expression, llvm::ScalarEvolution &SE);
|
llvm::ScalarEvolution &SE);
|
||||||
|
|
||||||
/// @brief Extract the constant factors from the multiplication @p M.
|
/// @brief Extract the constant factors from the multiplication @p M.
|
||||||
///
|
///
|
||||||
|
|
|
@ -41,6 +41,9 @@ using ValueMapT = llvm::DenseMap<llvm::AssertingVH<llvm::Value>,
|
||||||
/// @brief Type for a set of invariant loads.
|
/// @brief Type for a set of invariant loads.
|
||||||
using InvariantLoadsSetTy = llvm::SetVector<llvm::AssertingVH<llvm::LoadInst>>;
|
using InvariantLoadsSetTy = llvm::SetVector<llvm::AssertingVH<llvm::LoadInst>>;
|
||||||
|
|
||||||
|
/// @brief Set type for parameters.
|
||||||
|
using ParameterSetTy = llvm::SetVector<const llvm::SCEV *>;
|
||||||
|
|
||||||
/// @brief Utility proxy to wrap the common members of LoadInst and StoreInst.
|
/// @brief Utility proxy to wrap the common members of LoadInst and StoreInst.
|
||||||
///
|
///
|
||||||
/// This works like the LLVM utility class CallSite, ie. it forwards all calls
|
/// This works like the LLVM utility class CallSite, ie. it forwards all calls
|
||||||
|
|
|
@ -1803,7 +1803,7 @@ const SCEV *Scop::getRepresentingInvariantLoadSCEV(const SCEV *S) {
|
||||||
return SCEVSensitiveParameterRewriter::rewrite(S, *SE, InvEquivClassVMap);
|
return SCEVSensitiveParameterRewriter::rewrite(S, *SE, InvEquivClassVMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scop::addParams(std::vector<const SCEV *> NewParameters) {
|
void Scop::addParams(const ParameterSetTy &NewParameters) {
|
||||||
for (const SCEV *Parameter : NewParameters) {
|
for (const SCEV *Parameter : NewParameters) {
|
||||||
Parameter = extractConstantFactor(Parameter, *SE).second;
|
Parameter = extractConstantFactor(Parameter, *SE).second;
|
||||||
|
|
||||||
|
@ -1873,15 +1873,15 @@ void Scop::addUserAssumptions(AssumptionCache &AC, DominatorTree &DT,
|
||||||
|
|
||||||
auto *L = LI.getLoopFor(CI->getParent());
|
auto *L = LI.getLoopFor(CI->getParent());
|
||||||
auto *Val = CI->getArgOperand(0);
|
auto *Val = CI->getArgOperand(0);
|
||||||
std::vector<const SCEV *> Params;
|
ParameterSetTy DetectedParams;
|
||||||
if (!isAffineParamConstraint(Val, R, L, *SE, Params)) {
|
if (!isAffineParamConstraint(Val, R, L, *SE, DetectedParams)) {
|
||||||
emitOptimizationRemarkAnalysis(F.getContext(), DEBUG_TYPE, F,
|
emitOptimizationRemarkAnalysis(F.getContext(), DEBUG_TYPE, F,
|
||||||
CI->getDebugLoc(),
|
CI->getDebugLoc(),
|
||||||
"Non-affine user assumption ignored.");
|
"Non-affine user assumption ignored.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
addParams(Params);
|
addParams(DetectedParams);
|
||||||
|
|
||||||
SmallVector<isl_set *, 2> ConditionSets;
|
SmallVector<isl_set *, 2> ConditionSets;
|
||||||
buildConditionSets(*Stmts.begin(), Val, nullptr, L, Context, ConditionSets);
|
buildConditionSets(*Stmts.begin(), Val, nullptr, L, Context, ConditionSets);
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include "llvm/Analysis/ScalarEvolution.h"
|
#include "llvm/Analysis/ScalarEvolution.h"
|
||||||
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
|
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
using namespace polly;
|
using namespace polly;
|
||||||
|
@ -41,7 +40,7 @@ class ValidatorResult {
|
||||||
SCEVType::TYPE Type;
|
SCEVType::TYPE Type;
|
||||||
|
|
||||||
/// @brief The set of Parameters in the expression.
|
/// @brief The set of Parameters in the expression.
|
||||||
std::vector<const SCEV *> Parameters;
|
ParameterSetTy Parameters;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// @brief The copy constructor
|
/// @brief The copy constructor
|
||||||
|
@ -57,7 +56,7 @@ public:
|
||||||
|
|
||||||
/// @brief Construct a result with a certain type and a single parameter.
|
/// @brief Construct a result with a certain type and a single parameter.
|
||||||
ValidatorResult(SCEVType::TYPE Type, const SCEV *Expr) : Type(Type) {
|
ValidatorResult(SCEVType::TYPE Type, const SCEV *Expr) : Type(Type) {
|
||||||
Parameters.push_back(Expr);
|
Parameters.insert(Expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Get the type of the ValidatorResult.
|
/// @brief Get the type of the ValidatorResult.
|
||||||
|
@ -79,12 +78,11 @@ public:
|
||||||
bool isPARAM() { return Type == SCEVType::PARAM; }
|
bool isPARAM() { return Type == SCEVType::PARAM; }
|
||||||
|
|
||||||
/// @brief Get the parameters of this validator result.
|
/// @brief Get the parameters of this validator result.
|
||||||
std::vector<const SCEV *> getParameters() { return Parameters; }
|
const ParameterSetTy &getParameters() { return Parameters; }
|
||||||
|
|
||||||
/// @brief Add the parameters of Source to this result.
|
/// @brief Add the parameters of Source to this result.
|
||||||
void addParamsFrom(const ValidatorResult &Source) {
|
void addParamsFrom(const ValidatorResult &Source) {
|
||||||
Parameters.insert(Parameters.end(), Source.Parameters.begin(),
|
Parameters.insert(Source.Parameters.begin(), Source.Parameters.end());
|
||||||
Source.Parameters.end());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Merge a result.
|
/// @brief Merge a result.
|
||||||
|
@ -548,8 +546,7 @@ bool isAffineExpr(const Region *R, llvm::Loop *Scope, const SCEV *Expr,
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isAffineParamExpr(Value *V, const Region *R, Loop *Scope,
|
static bool isAffineParamExpr(Value *V, const Region *R, Loop *Scope,
|
||||||
ScalarEvolution &SE,
|
ScalarEvolution &SE, ParameterSetTy &Params) {
|
||||||
std::vector<const SCEV *> &Params) {
|
|
||||||
auto *E = SE.getSCEV(V);
|
auto *E = SE.getSCEV(V);
|
||||||
if (isa<SCEVCouldNotCompute>(E))
|
if (isa<SCEVCouldNotCompute>(E))
|
||||||
return false;
|
return false;
|
||||||
|
@ -560,14 +557,14 @@ static bool isAffineParamExpr(Value *V, const Region *R, Loop *Scope,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto ResultParams = Result.getParameters();
|
auto ResultParams = Result.getParameters();
|
||||||
Params.insert(Params.end(), ResultParams.begin(), ResultParams.end());
|
Params.insert(ResultParams.begin(), ResultParams.end());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAffineParamConstraint(Value *V, const Region *R, llvm::Loop *Scope,
|
bool isAffineParamConstraint(Value *V, const Region *R, llvm::Loop *Scope,
|
||||||
ScalarEvolution &SE,
|
ScalarEvolution &SE, ParameterSetTy &Params,
|
||||||
std::vector<const SCEV *> &Params, bool OrExpr) {
|
bool OrExpr) {
|
||||||
if (auto *ICmp = dyn_cast<ICmpInst>(V)) {
|
if (auto *ICmp = dyn_cast<ICmpInst>(V)) {
|
||||||
return isAffineParamConstraint(ICmp->getOperand(0), R, Scope, SE, Params,
|
return isAffineParamConstraint(ICmp->getOperand(0), R, Scope, SE, Params,
|
||||||
true) &&
|
true) &&
|
||||||
|
@ -589,11 +586,10 @@ bool isAffineParamConstraint(Value *V, const Region *R, llvm::Loop *Scope,
|
||||||
return isAffineParamExpr(V, R, Scope, SE, Params);
|
return isAffineParamExpr(V, R, Scope, SE, Params);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<const SCEV *> getParamsInAffineExpr(const Region *R, Loop *Scope,
|
ParameterSetTy getParamsInAffineExpr(const Region *R, Loop *Scope,
|
||||||
const SCEV *Expr,
|
const SCEV *Expr, ScalarEvolution &SE) {
|
||||||
ScalarEvolution &SE) {
|
|
||||||
if (isa<SCEVCouldNotCompute>(Expr))
|
if (isa<SCEVCouldNotCompute>(Expr))
|
||||||
return std::vector<const SCEV *>();
|
return ParameterSetTy();
|
||||||
|
|
||||||
InvariantLoadsSetTy ILS;
|
InvariantLoadsSetTy ILS;
|
||||||
SCEVValidator Validator(R, Scope, SE, &ILS);
|
SCEVValidator Validator(R, Scope, SE, &ILS);
|
||||||
|
|
Loading…
Reference in New Issue