forked from OSchip/llvm-project
parent
ec8a217729
commit
f560b3d2db
|
@ -1862,7 +1862,7 @@ public:
|
|||
inline const ParamVecType &getParams() const { return Parameters; }
|
||||
|
||||
/// @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(); }
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
#include "polly/Support/ScopHelper.h"
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
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.
|
||||
bool isAffineParamConstraint(llvm::Value *V, const llvm::Region *R,
|
||||
llvm::Loop *Scope, llvm::ScalarEvolution &SE,
|
||||
std::vector<const llvm::SCEV *> &Params,
|
||||
bool OrExpr = false);
|
||||
ParameterSetTy &Params, bool OrExpr = false);
|
||||
|
||||
std::vector<const llvm::SCEV *>
|
||||
getParamsInAffineExpr(const llvm::Region *R, llvm::Loop *Scope,
|
||||
const llvm::SCEV *Expression, llvm::ScalarEvolution &SE);
|
||||
ParameterSetTy getParamsInAffineExpr(const llvm::Region *R, llvm::Loop *Scope,
|
||||
const llvm::SCEV *Expression,
|
||||
llvm::ScalarEvolution &SE);
|
||||
|
||||
/// @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.
|
||||
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.
|
||||
///
|
||||
/// 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);
|
||||
}
|
||||
|
||||
void Scop::addParams(std::vector<const SCEV *> NewParameters) {
|
||||
void Scop::addParams(const ParameterSetTy &NewParameters) {
|
||||
for (const SCEV *Parameter : NewParameters) {
|
||||
Parameter = extractConstantFactor(Parameter, *SE).second;
|
||||
|
||||
|
@ -1873,15 +1873,15 @@ void Scop::addUserAssumptions(AssumptionCache &AC, DominatorTree &DT,
|
|||
|
||||
auto *L = LI.getLoopFor(CI->getParent());
|
||||
auto *Val = CI->getArgOperand(0);
|
||||
std::vector<const SCEV *> Params;
|
||||
if (!isAffineParamConstraint(Val, R, L, *SE, Params)) {
|
||||
ParameterSetTy DetectedParams;
|
||||
if (!isAffineParamConstraint(Val, R, L, *SE, DetectedParams)) {
|
||||
emitOptimizationRemarkAnalysis(F.getContext(), DEBUG_TYPE, F,
|
||||
CI->getDebugLoc(),
|
||||
"Non-affine user assumption ignored.");
|
||||
continue;
|
||||
}
|
||||
|
||||
addParams(Params);
|
||||
addParams(DetectedParams);
|
||||
|
||||
SmallVector<isl_set *, 2> ConditionSets;
|
||||
buildConditionSets(*Stmts.begin(), Val, nullptr, L, Context, ConditionSets);
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "llvm/Analysis/ScalarEvolution.h"
|
||||
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include <vector>
|
||||
|
||||
using namespace llvm;
|
||||
using namespace polly;
|
||||
|
@ -41,7 +40,7 @@ class ValidatorResult {
|
|||
SCEVType::TYPE Type;
|
||||
|
||||
/// @brief The set of Parameters in the expression.
|
||||
std::vector<const SCEV *> Parameters;
|
||||
ParameterSetTy Parameters;
|
||||
|
||||
public:
|
||||
/// @brief The copy constructor
|
||||
|
@ -57,7 +56,7 @@ public:
|
|||
|
||||
/// @brief Construct a result with a certain type and a single parameter.
|
||||
ValidatorResult(SCEVType::TYPE Type, const SCEV *Expr) : Type(Type) {
|
||||
Parameters.push_back(Expr);
|
||||
Parameters.insert(Expr);
|
||||
}
|
||||
|
||||
/// @brief Get the type of the ValidatorResult.
|
||||
|
@ -79,12 +78,11 @@ public:
|
|||
bool isPARAM() { return Type == SCEVType::PARAM; }
|
||||
|
||||
/// @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.
|
||||
void addParamsFrom(const ValidatorResult &Source) {
|
||||
Parameters.insert(Parameters.end(), Source.Parameters.begin(),
|
||||
Source.Parameters.end());
|
||||
Parameters.insert(Source.Parameters.begin(), Source.Parameters.end());
|
||||
}
|
||||
|
||||
/// @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,
|
||||
ScalarEvolution &SE,
|
||||
std::vector<const SCEV *> &Params) {
|
||||
ScalarEvolution &SE, ParameterSetTy &Params) {
|
||||
auto *E = SE.getSCEV(V);
|
||||
if (isa<SCEVCouldNotCompute>(E))
|
||||
return false;
|
||||
|
@ -560,14 +557,14 @@ static bool isAffineParamExpr(Value *V, const Region *R, Loop *Scope,
|
|||
return false;
|
||||
|
||||
auto ResultParams = Result.getParameters();
|
||||
Params.insert(Params.end(), ResultParams.begin(), ResultParams.end());
|
||||
Params.insert(ResultParams.begin(), ResultParams.end());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isAffineParamConstraint(Value *V, const Region *R, llvm::Loop *Scope,
|
||||
ScalarEvolution &SE,
|
||||
std::vector<const SCEV *> &Params, bool OrExpr) {
|
||||
ScalarEvolution &SE, ParameterSetTy &Params,
|
||||
bool OrExpr) {
|
||||
if (auto *ICmp = dyn_cast<ICmpInst>(V)) {
|
||||
return isAffineParamConstraint(ICmp->getOperand(0), R, Scope, SE, Params,
|
||||
true) &&
|
||||
|
@ -589,11 +586,10 @@ bool isAffineParamConstraint(Value *V, const Region *R, llvm::Loop *Scope,
|
|||
return isAffineParamExpr(V, R, Scope, SE, Params);
|
||||
}
|
||||
|
||||
std::vector<const SCEV *> getParamsInAffineExpr(const Region *R, Loop *Scope,
|
||||
const SCEV *Expr,
|
||||
ScalarEvolution &SE) {
|
||||
ParameterSetTy getParamsInAffineExpr(const Region *R, Loop *Scope,
|
||||
const SCEV *Expr, ScalarEvolution &SE) {
|
||||
if (isa<SCEVCouldNotCompute>(Expr))
|
||||
return std::vector<const SCEV *>();
|
||||
return ParameterSetTy();
|
||||
|
||||
InvariantLoadsSetTy ILS;
|
||||
SCEVValidator Validator(R, Scope, SE, &ILS);
|
||||
|
|
Loading…
Reference in New Issue