mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-14 13:07:31 +00:00
Convert several parts of the ScalarEvolution framework to use
SmallVector instead of std::vector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73357 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ea73f3c2e1
commit
a82752c9eb
@ -394,24 +394,24 @@ namespace llvm {
|
|||||||
SCEVHandle getZeroExtendExpr(const SCEVHandle &Op, const Type *Ty);
|
SCEVHandle getZeroExtendExpr(const SCEVHandle &Op, const Type *Ty);
|
||||||
SCEVHandle getSignExtendExpr(const SCEVHandle &Op, const Type *Ty);
|
SCEVHandle getSignExtendExpr(const SCEVHandle &Op, const Type *Ty);
|
||||||
SCEVHandle getAnyExtendExpr(const SCEVHandle &Op, const Type *Ty);
|
SCEVHandle getAnyExtendExpr(const SCEVHandle &Op, const Type *Ty);
|
||||||
SCEVHandle getAddExpr(std::vector<SCEVHandle> &Ops);
|
SCEVHandle getAddExpr(SmallVectorImpl<SCEVHandle> &Ops);
|
||||||
SCEVHandle getAddExpr(const SCEVHandle &LHS, const SCEVHandle &RHS) {
|
SCEVHandle getAddExpr(const SCEVHandle &LHS, const SCEVHandle &RHS) {
|
||||||
std::vector<SCEVHandle> Ops;
|
SmallVector<SCEVHandle, 2> Ops;
|
||||||
Ops.push_back(LHS);
|
Ops.push_back(LHS);
|
||||||
Ops.push_back(RHS);
|
Ops.push_back(RHS);
|
||||||
return getAddExpr(Ops);
|
return getAddExpr(Ops);
|
||||||
}
|
}
|
||||||
SCEVHandle getAddExpr(const SCEVHandle &Op0, const SCEVHandle &Op1,
|
SCEVHandle getAddExpr(const SCEVHandle &Op0, const SCEVHandle &Op1,
|
||||||
const SCEVHandle &Op2) {
|
const SCEVHandle &Op2) {
|
||||||
std::vector<SCEVHandle> Ops;
|
SmallVector<SCEVHandle, 3> Ops;
|
||||||
Ops.push_back(Op0);
|
Ops.push_back(Op0);
|
||||||
Ops.push_back(Op1);
|
Ops.push_back(Op1);
|
||||||
Ops.push_back(Op2);
|
Ops.push_back(Op2);
|
||||||
return getAddExpr(Ops);
|
return getAddExpr(Ops);
|
||||||
}
|
}
|
||||||
SCEVHandle getMulExpr(std::vector<SCEVHandle> &Ops);
|
SCEVHandle getMulExpr(SmallVectorImpl<SCEVHandle> &Ops);
|
||||||
SCEVHandle getMulExpr(const SCEVHandle &LHS, const SCEVHandle &RHS) {
|
SCEVHandle getMulExpr(const SCEVHandle &LHS, const SCEVHandle &RHS) {
|
||||||
std::vector<SCEVHandle> Ops;
|
SmallVector<SCEVHandle, 2> Ops;
|
||||||
Ops.push_back(LHS);
|
Ops.push_back(LHS);
|
||||||
Ops.push_back(RHS);
|
Ops.push_back(RHS);
|
||||||
return getMulExpr(Ops);
|
return getMulExpr(Ops);
|
||||||
@ -419,17 +419,17 @@ namespace llvm {
|
|||||||
SCEVHandle getUDivExpr(const SCEVHandle &LHS, const SCEVHandle &RHS);
|
SCEVHandle getUDivExpr(const SCEVHandle &LHS, const SCEVHandle &RHS);
|
||||||
SCEVHandle getAddRecExpr(const SCEVHandle &Start, const SCEVHandle &Step,
|
SCEVHandle getAddRecExpr(const SCEVHandle &Start, const SCEVHandle &Step,
|
||||||
const Loop *L);
|
const Loop *L);
|
||||||
SCEVHandle getAddRecExpr(std::vector<SCEVHandle> &Operands,
|
SCEVHandle getAddRecExpr(SmallVectorImpl<SCEVHandle> &Operands,
|
||||||
const Loop *L);
|
const Loop *L);
|
||||||
SCEVHandle getAddRecExpr(const std::vector<SCEVHandle> &Operands,
|
SCEVHandle getAddRecExpr(const SmallVectorImpl<SCEVHandle> &Operands,
|
||||||
const Loop *L) {
|
const Loop *L) {
|
||||||
std::vector<SCEVHandle> NewOp(Operands);
|
SmallVector<SCEVHandle, 4> NewOp(Operands.begin(), Operands.end());
|
||||||
return getAddRecExpr(NewOp, L);
|
return getAddRecExpr(NewOp, L);
|
||||||
}
|
}
|
||||||
SCEVHandle getSMaxExpr(const SCEVHandle &LHS, const SCEVHandle &RHS);
|
SCEVHandle getSMaxExpr(const SCEVHandle &LHS, const SCEVHandle &RHS);
|
||||||
SCEVHandle getSMaxExpr(std::vector<SCEVHandle> Operands);
|
SCEVHandle getSMaxExpr(SmallVectorImpl<SCEVHandle> &Operands);
|
||||||
SCEVHandle getUMaxExpr(const SCEVHandle &LHS, const SCEVHandle &RHS);
|
SCEVHandle getUMaxExpr(const SCEVHandle &LHS, const SCEVHandle &RHS);
|
||||||
SCEVHandle getUMaxExpr(std::vector<SCEVHandle> Operands);
|
SCEVHandle getUMaxExpr(SmallVectorImpl<SCEVHandle> &Operands);
|
||||||
SCEVHandle getUnknown(Value *V);
|
SCEVHandle getUnknown(Value *V);
|
||||||
SCEVHandle getCouldNotCompute();
|
SCEVHandle getCouldNotCompute();
|
||||||
|
|
||||||
|
@ -199,10 +199,10 @@ namespace llvm {
|
|||||||
///
|
///
|
||||||
class SCEVNAryExpr : public SCEV {
|
class SCEVNAryExpr : public SCEV {
|
||||||
protected:
|
protected:
|
||||||
std::vector<SCEVHandle> Operands;
|
SmallVector<SCEVHandle, 8> Operands;
|
||||||
|
|
||||||
SCEVNAryExpr(enum SCEVTypes T, const std::vector<SCEVHandle> &ops)
|
SCEVNAryExpr(enum SCEVTypes T, const SmallVectorImpl<SCEVHandle> &ops)
|
||||||
: SCEV(T), Operands(ops) {}
|
: SCEV(T), Operands(ops.begin(), ops.end()) {}
|
||||||
virtual ~SCEVNAryExpr() {}
|
virtual ~SCEVNAryExpr() {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -212,8 +212,8 @@ namespace llvm {
|
|||||||
return Operands[i];
|
return Operands[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<SCEVHandle> &getOperands() const { return Operands; }
|
const SmallVectorImpl<SCEVHandle> &getOperands() const { return Operands; }
|
||||||
typedef std::vector<SCEVHandle>::const_iterator op_iterator;
|
typedef SmallVectorImpl<SCEVHandle>::const_iterator op_iterator;
|
||||||
op_iterator op_begin() const { return Operands.begin(); }
|
op_iterator op_begin() const { return Operands.begin(); }
|
||||||
op_iterator op_end() const { return Operands.end(); }
|
op_iterator op_end() const { return Operands.end(); }
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ namespace llvm {
|
|||||||
///
|
///
|
||||||
class SCEVCommutativeExpr : public SCEVNAryExpr {
|
class SCEVCommutativeExpr : public SCEVNAryExpr {
|
||||||
protected:
|
protected:
|
||||||
SCEVCommutativeExpr(enum SCEVTypes T, const std::vector<SCEVHandle> &ops)
|
SCEVCommutativeExpr(enum SCEVTypes T, const SmallVectorImpl<SCEVHandle> &ops)
|
||||||
: SCEVNAryExpr(T, ops) {}
|
: SCEVNAryExpr(T, ops) {}
|
||||||
~SCEVCommutativeExpr();
|
~SCEVCommutativeExpr();
|
||||||
|
|
||||||
@ -289,7 +289,7 @@ namespace llvm {
|
|||||||
class SCEVAddExpr : public SCEVCommutativeExpr {
|
class SCEVAddExpr : public SCEVCommutativeExpr {
|
||||||
friend class ScalarEvolution;
|
friend class ScalarEvolution;
|
||||||
|
|
||||||
explicit SCEVAddExpr(const std::vector<SCEVHandle> &ops)
|
explicit SCEVAddExpr(const SmallVectorImpl<SCEVHandle> &ops)
|
||||||
: SCEVCommutativeExpr(scAddExpr, ops) {
|
: SCEVCommutativeExpr(scAddExpr, ops) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,7 +309,7 @@ namespace llvm {
|
|||||||
class SCEVMulExpr : public SCEVCommutativeExpr {
|
class SCEVMulExpr : public SCEVCommutativeExpr {
|
||||||
friend class ScalarEvolution;
|
friend class ScalarEvolution;
|
||||||
|
|
||||||
explicit SCEVMulExpr(const std::vector<SCEVHandle> &ops)
|
explicit SCEVMulExpr(const SmallVectorImpl<SCEVHandle> &ops)
|
||||||
: SCEVCommutativeExpr(scMulExpr, ops) {
|
: SCEVCommutativeExpr(scMulExpr, ops) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,7 +387,7 @@ namespace llvm {
|
|||||||
|
|
||||||
const Loop *L;
|
const Loop *L;
|
||||||
|
|
||||||
SCEVAddRecExpr(const std::vector<SCEVHandle> &ops, const Loop *l)
|
SCEVAddRecExpr(const SmallVectorImpl<SCEVHandle> &ops, const Loop *l)
|
||||||
: SCEVNAryExpr(scAddRecExpr, ops), L(l) {
|
: SCEVNAryExpr(scAddRecExpr, ops), L(l) {
|
||||||
for (size_t i = 0, e = Operands.size(); i != e; ++i)
|
for (size_t i = 0, e = Operands.size(); i != e; ++i)
|
||||||
assert(Operands[i]->isLoopInvariant(l) &&
|
assert(Operands[i]->isLoopInvariant(l) &&
|
||||||
@ -404,7 +404,7 @@ namespace llvm {
|
|||||||
/// of degree N, it returns a chrec of degree N-1.
|
/// of degree N, it returns a chrec of degree N-1.
|
||||||
SCEVHandle getStepRecurrence(ScalarEvolution &SE) const {
|
SCEVHandle getStepRecurrence(ScalarEvolution &SE) const {
|
||||||
if (isAffine()) return getOperand(1);
|
if (isAffine()) return getOperand(1);
|
||||||
return SE.getAddRecExpr(std::vector<SCEVHandle>(op_begin()+1,op_end()),
|
return SE.getAddRecExpr(SmallVector<SCEVHandle, 3>(op_begin()+1,op_end()),
|
||||||
getLoop());
|
getLoop());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,7 +463,7 @@ namespace llvm {
|
|||||||
class SCEVSMaxExpr : public SCEVCommutativeExpr {
|
class SCEVSMaxExpr : public SCEVCommutativeExpr {
|
||||||
friend class ScalarEvolution;
|
friend class ScalarEvolution;
|
||||||
|
|
||||||
explicit SCEVSMaxExpr(const std::vector<SCEVHandle> &ops)
|
explicit SCEVSMaxExpr(const SmallVectorImpl<SCEVHandle> &ops)
|
||||||
: SCEVCommutativeExpr(scSMaxExpr, ops) {
|
: SCEVCommutativeExpr(scSMaxExpr, ops) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,7 +484,7 @@ namespace llvm {
|
|||||||
class SCEVUMaxExpr : public SCEVCommutativeExpr {
|
class SCEVUMaxExpr : public SCEVCommutativeExpr {
|
||||||
friend class ScalarEvolution;
|
friend class ScalarEvolution;
|
||||||
|
|
||||||
explicit SCEVUMaxExpr(const std::vector<SCEVHandle> &ops)
|
explicit SCEVUMaxExpr(const SmallVectorImpl<SCEVHandle> &ops)
|
||||||
: SCEVCommutativeExpr(scUMaxExpr, ops) {
|
: SCEVCommutativeExpr(scUMaxExpr, ops) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym,
|
|||||||
SCEVHandle H =
|
SCEVHandle H =
|
||||||
getOperand(i)->replaceSymbolicValuesWithConcrete(Sym, Conc, SE);
|
getOperand(i)->replaceSymbolicValuesWithConcrete(Sym, Conc, SE);
|
||||||
if (H != getOperand(i)) {
|
if (H != getOperand(i)) {
|
||||||
std::vector<SCEVHandle> NewOps;
|
SmallVector<SCEVHandle, 8> NewOps;
|
||||||
NewOps.reserve(getNumOperands());
|
NewOps.reserve(getNumOperands());
|
||||||
for (unsigned j = 0; j != i; ++j)
|
for (unsigned j = 0; j != i; ++j)
|
||||||
NewOps.push_back(getOperand(j));
|
NewOps.push_back(getOperand(j));
|
||||||
@ -373,7 +373,7 @@ replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym,
|
|||||||
SCEVHandle H =
|
SCEVHandle H =
|
||||||
getOperand(i)->replaceSymbolicValuesWithConcrete(Sym, Conc, SE);
|
getOperand(i)->replaceSymbolicValuesWithConcrete(Sym, Conc, SE);
|
||||||
if (H != getOperand(i)) {
|
if (H != getOperand(i)) {
|
||||||
std::vector<SCEVHandle> NewOps;
|
SmallVector<SCEVHandle, 8> NewOps;
|
||||||
NewOps.reserve(getNumOperands());
|
NewOps.reserve(getNumOperands());
|
||||||
for (unsigned j = 0; j != i; ++j)
|
for (unsigned j = 0; j != i; ++j)
|
||||||
NewOps.push_back(getOperand(j));
|
NewOps.push_back(getOperand(j));
|
||||||
@ -558,7 +558,7 @@ namespace {
|
|||||||
/// this to depend on where the addresses of various SCEV objects happened to
|
/// this to depend on where the addresses of various SCEV objects happened to
|
||||||
/// land in memory.
|
/// land in memory.
|
||||||
///
|
///
|
||||||
static void GroupByComplexity(std::vector<SCEVHandle> &Ops,
|
static void GroupByComplexity(SmallVectorImpl<SCEVHandle> &Ops,
|
||||||
LoopInfo *LI) {
|
LoopInfo *LI) {
|
||||||
if (Ops.size() < 2) return; // Noop
|
if (Ops.size() < 2) return; // Noop
|
||||||
if (Ops.size() == 2) {
|
if (Ops.size() == 2) {
|
||||||
@ -766,7 +766,7 @@ SCEVHandle ScalarEvolution::getTruncateExpr(const SCEVHandle &Op,
|
|||||||
// If the input value is a chrec scev made out of constants, truncate
|
// If the input value is a chrec scev made out of constants, truncate
|
||||||
// all of the constants.
|
// all of the constants.
|
||||||
if (const SCEVAddRecExpr *AddRec = dyn_cast<SCEVAddRecExpr>(Op)) {
|
if (const SCEVAddRecExpr *AddRec = dyn_cast<SCEVAddRecExpr>(Op)) {
|
||||||
std::vector<SCEVHandle> Operands;
|
SmallVector<SCEVHandle, 4> Operands;
|
||||||
for (unsigned i = 0, e = AddRec->getNumOperands(); i != e; ++i)
|
for (unsigned i = 0, e = AddRec->getNumOperands(); i != e; ++i)
|
||||||
Operands.push_back(getTruncateExpr(AddRec->getOperand(i), Ty));
|
Operands.push_back(getTruncateExpr(AddRec->getOperand(i), Ty));
|
||||||
return getAddRecExpr(Operands, AddRec->getLoop());
|
return getAddRecExpr(Operands, AddRec->getLoop());
|
||||||
@ -981,7 +981,7 @@ SCEVHandle ScalarEvolution::getAnyExtendExpr(const SCEVHandle &Op,
|
|||||||
|
|
||||||
/// getAddExpr - Get a canonical add expression, or something simpler if
|
/// getAddExpr - Get a canonical add expression, or something simpler if
|
||||||
/// possible.
|
/// possible.
|
||||||
SCEVHandle ScalarEvolution::getAddExpr(std::vector<SCEVHandle> &Ops) {
|
SCEVHandle ScalarEvolution::getAddExpr(SmallVectorImpl<SCEVHandle> &Ops) {
|
||||||
assert(!Ops.empty() && "Cannot get empty add!");
|
assert(!Ops.empty() && "Cannot get empty add!");
|
||||||
if (Ops.size() == 1) return Ops[0];
|
if (Ops.size() == 1) return Ops[0];
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
@ -1001,9 +1001,8 @@ SCEVHandle ScalarEvolution::getAddExpr(std::vector<SCEVHandle> &Ops) {
|
|||||||
assert(Idx < Ops.size());
|
assert(Idx < Ops.size());
|
||||||
while (const SCEVConstant *RHSC = dyn_cast<SCEVConstant>(Ops[Idx])) {
|
while (const SCEVConstant *RHSC = dyn_cast<SCEVConstant>(Ops[Idx])) {
|
||||||
// We found two constants, fold them together!
|
// We found two constants, fold them together!
|
||||||
ConstantInt *Fold = ConstantInt::get(LHSC->getValue()->getValue() +
|
Ops[0] = getConstant(LHSC->getValue()->getValue() +
|
||||||
RHSC->getValue()->getValue());
|
RHSC->getValue()->getValue());
|
||||||
Ops[0] = getConstant(Fold);
|
|
||||||
Ops.erase(Ops.begin()+1); // Erase the folded element
|
Ops.erase(Ops.begin()+1); // Erase the folded element
|
||||||
if (Ops.size() == 1) return Ops[0];
|
if (Ops.size() == 1) return Ops[0];
|
||||||
LHSC = cast<SCEVConstant>(Ops[0]);
|
LHSC = cast<SCEVConstant>(Ops[0]);
|
||||||
@ -1043,7 +1042,7 @@ SCEVHandle ScalarEvolution::getAddExpr(std::vector<SCEVHandle> &Ops) {
|
|||||||
const SCEVTruncateExpr *Trunc = cast<SCEVTruncateExpr>(Ops[Idx]);
|
const SCEVTruncateExpr *Trunc = cast<SCEVTruncateExpr>(Ops[Idx]);
|
||||||
const Type *DstType = Trunc->getType();
|
const Type *DstType = Trunc->getType();
|
||||||
const Type *SrcType = Trunc->getOperand()->getType();
|
const Type *SrcType = Trunc->getOperand()->getType();
|
||||||
std::vector<SCEVHandle> LargeOps;
|
SmallVector<SCEVHandle, 8> LargeOps;
|
||||||
bool Ok = true;
|
bool Ok = true;
|
||||||
// Check all the operands to see if they can be represented in the
|
// Check all the operands to see if they can be represented in the
|
||||||
// source type of the truncate.
|
// source type of the truncate.
|
||||||
@ -1059,7 +1058,7 @@ SCEVHandle ScalarEvolution::getAddExpr(std::vector<SCEVHandle> &Ops) {
|
|||||||
// is much more likely to be foldable here.
|
// is much more likely to be foldable here.
|
||||||
LargeOps.push_back(getSignExtendExpr(C, SrcType));
|
LargeOps.push_back(getSignExtendExpr(C, SrcType));
|
||||||
} else if (const SCEVMulExpr *M = dyn_cast<SCEVMulExpr>(Ops[i])) {
|
} else if (const SCEVMulExpr *M = dyn_cast<SCEVMulExpr>(Ops[i])) {
|
||||||
std::vector<SCEVHandle> LargeMulOps;
|
SmallVector<SCEVHandle, 8> LargeMulOps;
|
||||||
for (unsigned j = 0, f = M->getNumOperands(); j != f && Ok; ++j) {
|
for (unsigned j = 0, f = M->getNumOperands(); j != f && Ok; ++j) {
|
||||||
if (const SCEVTruncateExpr *T =
|
if (const SCEVTruncateExpr *T =
|
||||||
dyn_cast<SCEVTruncateExpr>(M->getOperand(j))) {
|
dyn_cast<SCEVTruncateExpr>(M->getOperand(j))) {
|
||||||
@ -1128,13 +1127,13 @@ SCEVHandle ScalarEvolution::getAddExpr(std::vector<SCEVHandle> &Ops) {
|
|||||||
for (unsigned MulOp = 0, e = Mul->getNumOperands(); MulOp != e; ++MulOp) {
|
for (unsigned MulOp = 0, e = Mul->getNumOperands(); MulOp != e; ++MulOp) {
|
||||||
const SCEV *MulOpSCEV = Mul->getOperand(MulOp);
|
const SCEV *MulOpSCEV = Mul->getOperand(MulOp);
|
||||||
for (unsigned AddOp = 0, e = Ops.size(); AddOp != e; ++AddOp)
|
for (unsigned AddOp = 0, e = Ops.size(); AddOp != e; ++AddOp)
|
||||||
if (MulOpSCEV == Ops[AddOp] && !isa<SCEVConstant>(MulOpSCEV)) {
|
if (MulOpSCEV == Ops[AddOp] && !isa<SCEVConstant>(Ops[AddOp])) {
|
||||||
// Fold W + X + (X * Y * Z) --> W + (X * ((Y*Z)+1))
|
// Fold W + X + (X * Y * Z) --> W + (X * ((Y*Z)+1))
|
||||||
SCEVHandle InnerMul = Mul->getOperand(MulOp == 0);
|
SCEVHandle InnerMul = Mul->getOperand(MulOp == 0);
|
||||||
if (Mul->getNumOperands() != 2) {
|
if (Mul->getNumOperands() != 2) {
|
||||||
// If the multiply has more than two operands, we must get the
|
// If the multiply has more than two operands, we must get the
|
||||||
// Y*Z term.
|
// Y*Z term.
|
||||||
std::vector<SCEVHandle> MulOps(Mul->op_begin(), Mul->op_end());
|
SmallVector<SCEVHandle, 4> MulOps(Mul->op_begin(), Mul->op_end());
|
||||||
MulOps.erase(MulOps.begin()+MulOp);
|
MulOps.erase(MulOps.begin()+MulOp);
|
||||||
InnerMul = getMulExpr(MulOps);
|
InnerMul = getMulExpr(MulOps);
|
||||||
}
|
}
|
||||||
@ -1166,13 +1165,13 @@ SCEVHandle ScalarEvolution::getAddExpr(std::vector<SCEVHandle> &Ops) {
|
|||||||
// Fold X + (A*B*C) + (A*D*E) --> X + (A*(B*C+D*E))
|
// Fold X + (A*B*C) + (A*D*E) --> X + (A*(B*C+D*E))
|
||||||
SCEVHandle InnerMul1 = Mul->getOperand(MulOp == 0);
|
SCEVHandle InnerMul1 = Mul->getOperand(MulOp == 0);
|
||||||
if (Mul->getNumOperands() != 2) {
|
if (Mul->getNumOperands() != 2) {
|
||||||
std::vector<SCEVHandle> MulOps(Mul->op_begin(), Mul->op_end());
|
SmallVector<SCEVHandle, 4> MulOps(Mul->op_begin(), Mul->op_end());
|
||||||
MulOps.erase(MulOps.begin()+MulOp);
|
MulOps.erase(MulOps.begin()+MulOp);
|
||||||
InnerMul1 = getMulExpr(MulOps);
|
InnerMul1 = getMulExpr(MulOps);
|
||||||
}
|
}
|
||||||
SCEVHandle InnerMul2 = OtherMul->getOperand(OMulOp == 0);
|
SCEVHandle InnerMul2 = OtherMul->getOperand(OMulOp == 0);
|
||||||
if (OtherMul->getNumOperands() != 2) {
|
if (OtherMul->getNumOperands() != 2) {
|
||||||
std::vector<SCEVHandle> MulOps(OtherMul->op_begin(),
|
SmallVector<SCEVHandle, 4> MulOps(OtherMul->op_begin(),
|
||||||
OtherMul->op_end());
|
OtherMul->op_end());
|
||||||
MulOps.erase(MulOps.begin()+OMulOp);
|
MulOps.erase(MulOps.begin()+OMulOp);
|
||||||
InnerMul2 = getMulExpr(MulOps);
|
InnerMul2 = getMulExpr(MulOps);
|
||||||
@ -1199,7 +1198,7 @@ SCEVHandle ScalarEvolution::getAddExpr(std::vector<SCEVHandle> &Ops) {
|
|||||||
for (; Idx < Ops.size() && isa<SCEVAddRecExpr>(Ops[Idx]); ++Idx) {
|
for (; Idx < Ops.size() && isa<SCEVAddRecExpr>(Ops[Idx]); ++Idx) {
|
||||||
// Scan all of the other operands to this add and add them to the vector if
|
// Scan all of the other operands to this add and add them to the vector if
|
||||||
// they are loop invariant w.r.t. the recurrence.
|
// they are loop invariant w.r.t. the recurrence.
|
||||||
std::vector<SCEVHandle> LIOps;
|
SmallVector<SCEVHandle, 8> LIOps;
|
||||||
const SCEVAddRecExpr *AddRec = cast<SCEVAddRecExpr>(Ops[Idx]);
|
const SCEVAddRecExpr *AddRec = cast<SCEVAddRecExpr>(Ops[Idx]);
|
||||||
for (unsigned i = 0, e = Ops.size(); i != e; ++i)
|
for (unsigned i = 0, e = Ops.size(); i != e; ++i)
|
||||||
if (Ops[i]->isLoopInvariant(AddRec->getLoop())) {
|
if (Ops[i]->isLoopInvariant(AddRec->getLoop())) {
|
||||||
@ -1213,7 +1212,8 @@ SCEVHandle ScalarEvolution::getAddExpr(std::vector<SCEVHandle> &Ops) {
|
|||||||
// NLI + LI + {Start,+,Step} --> NLI + {LI+Start,+,Step}
|
// NLI + LI + {Start,+,Step} --> NLI + {LI+Start,+,Step}
|
||||||
LIOps.push_back(AddRec->getStart());
|
LIOps.push_back(AddRec->getStart());
|
||||||
|
|
||||||
std::vector<SCEVHandle> AddRecOps(AddRec->op_begin(), AddRec->op_end());
|
SmallVector<SCEVHandle, 4> AddRecOps(AddRec->op_begin(),
|
||||||
|
AddRec->op_end());
|
||||||
AddRecOps[0] = getAddExpr(LIOps);
|
AddRecOps[0] = getAddExpr(LIOps);
|
||||||
|
|
||||||
SCEVHandle NewRec = getAddRecExpr(AddRecOps, AddRec->getLoop());
|
SCEVHandle NewRec = getAddRecExpr(AddRecOps, AddRec->getLoop());
|
||||||
@ -1238,7 +1238,7 @@ SCEVHandle ScalarEvolution::getAddExpr(std::vector<SCEVHandle> &Ops) {
|
|||||||
const SCEVAddRecExpr *OtherAddRec = cast<SCEVAddRecExpr>(Ops[OtherIdx]);
|
const SCEVAddRecExpr *OtherAddRec = cast<SCEVAddRecExpr>(Ops[OtherIdx]);
|
||||||
if (AddRec->getLoop() == OtherAddRec->getLoop()) {
|
if (AddRec->getLoop() == OtherAddRec->getLoop()) {
|
||||||
// Other + {A,+,B} + {C,+,D} --> Other + {A+C,+,B+D}
|
// Other + {A,+,B} + {C,+,D} --> Other + {A+C,+,B+D}
|
||||||
std::vector<SCEVHandle> NewOps(AddRec->op_begin(), AddRec->op_end());
|
SmallVector<SCEVHandle, 4> NewOps(AddRec->op_begin(), AddRec->op_end());
|
||||||
for (unsigned i = 0, e = OtherAddRec->getNumOperands(); i != e; ++i) {
|
for (unsigned i = 0, e = OtherAddRec->getNumOperands(); i != e; ++i) {
|
||||||
if (i >= NewOps.size()) {
|
if (i >= NewOps.size()) {
|
||||||
NewOps.insert(NewOps.end(), OtherAddRec->op_begin()+i,
|
NewOps.insert(NewOps.end(), OtherAddRec->op_begin()+i,
|
||||||
@ -1274,7 +1274,7 @@ SCEVHandle ScalarEvolution::getAddExpr(std::vector<SCEVHandle> &Ops) {
|
|||||||
|
|
||||||
/// getMulExpr - Get a canonical multiply expression, or something simpler if
|
/// getMulExpr - Get a canonical multiply expression, or something simpler if
|
||||||
/// possible.
|
/// possible.
|
||||||
SCEVHandle ScalarEvolution::getMulExpr(std::vector<SCEVHandle> &Ops) {
|
SCEVHandle ScalarEvolution::getMulExpr(SmallVectorImpl<SCEVHandle> &Ops) {
|
||||||
assert(!Ops.empty() && "Cannot get empty mul!");
|
assert(!Ops.empty() && "Cannot get empty mul!");
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
for (unsigned i = 1, e = Ops.size(); i != e; ++i)
|
for (unsigned i = 1, e = Ops.size(); i != e; ++i)
|
||||||
@ -1355,7 +1355,7 @@ SCEVHandle ScalarEvolution::getMulExpr(std::vector<SCEVHandle> &Ops) {
|
|||||||
for (; Idx < Ops.size() && isa<SCEVAddRecExpr>(Ops[Idx]); ++Idx) {
|
for (; Idx < Ops.size() && isa<SCEVAddRecExpr>(Ops[Idx]); ++Idx) {
|
||||||
// Scan all of the other operands to this mul and add them to the vector if
|
// Scan all of the other operands to this mul and add them to the vector if
|
||||||
// they are loop invariant w.r.t. the recurrence.
|
// they are loop invariant w.r.t. the recurrence.
|
||||||
std::vector<SCEVHandle> LIOps;
|
SmallVector<SCEVHandle, 8> LIOps;
|
||||||
const SCEVAddRecExpr *AddRec = cast<SCEVAddRecExpr>(Ops[Idx]);
|
const SCEVAddRecExpr *AddRec = cast<SCEVAddRecExpr>(Ops[Idx]);
|
||||||
for (unsigned i = 0, e = Ops.size(); i != e; ++i)
|
for (unsigned i = 0, e = Ops.size(); i != e; ++i)
|
||||||
if (Ops[i]->isLoopInvariant(AddRec->getLoop())) {
|
if (Ops[i]->isLoopInvariant(AddRec->getLoop())) {
|
||||||
@ -1367,7 +1367,7 @@ SCEVHandle ScalarEvolution::getMulExpr(std::vector<SCEVHandle> &Ops) {
|
|||||||
// If we found some loop invariants, fold them into the recurrence.
|
// If we found some loop invariants, fold them into the recurrence.
|
||||||
if (!LIOps.empty()) {
|
if (!LIOps.empty()) {
|
||||||
// NLI * LI * {Start,+,Step} --> NLI * {LI*Start,+,LI*Step}
|
// NLI * LI * {Start,+,Step} --> NLI * {LI*Start,+,LI*Step}
|
||||||
std::vector<SCEVHandle> NewOps;
|
SmallVector<SCEVHandle, 4> NewOps;
|
||||||
NewOps.reserve(AddRec->getNumOperands());
|
NewOps.reserve(AddRec->getNumOperands());
|
||||||
if (LIOps.size() == 1) {
|
if (LIOps.size() == 1) {
|
||||||
const SCEV *Scale = LIOps[0];
|
const SCEV *Scale = LIOps[0];
|
||||||
@ -1375,7 +1375,7 @@ SCEVHandle ScalarEvolution::getMulExpr(std::vector<SCEVHandle> &Ops) {
|
|||||||
NewOps.push_back(getMulExpr(Scale, AddRec->getOperand(i)));
|
NewOps.push_back(getMulExpr(Scale, AddRec->getOperand(i)));
|
||||||
} else {
|
} else {
|
||||||
for (unsigned i = 0, e = AddRec->getNumOperands(); i != e; ++i) {
|
for (unsigned i = 0, e = AddRec->getNumOperands(); i != e; ++i) {
|
||||||
std::vector<SCEVHandle> MulOps(LIOps);
|
SmallVector<SCEVHandle, 4> MulOps(LIOps.begin(), LIOps.end());
|
||||||
MulOps.push_back(AddRec->getOperand(i));
|
MulOps.push_back(AddRec->getOperand(i));
|
||||||
NewOps.push_back(getMulExpr(MulOps));
|
NewOps.push_back(getMulExpr(MulOps));
|
||||||
}
|
}
|
||||||
@ -1473,14 +1473,14 @@ SCEVHandle ScalarEvolution::getUDivExpr(const SCEVHandle &LHS,
|
|||||||
getAddRecExpr(getZeroExtendExpr(AR->getStart(), ExtTy),
|
getAddRecExpr(getZeroExtendExpr(AR->getStart(), ExtTy),
|
||||||
getZeroExtendExpr(Step, ExtTy),
|
getZeroExtendExpr(Step, ExtTy),
|
||||||
AR->getLoop())) {
|
AR->getLoop())) {
|
||||||
std::vector<SCEVHandle> Operands;
|
SmallVector<SCEVHandle, 4> Operands;
|
||||||
for (unsigned i = 0, e = AR->getNumOperands(); i != e; ++i)
|
for (unsigned i = 0, e = AR->getNumOperands(); i != e; ++i)
|
||||||
Operands.push_back(getUDivExpr(AR->getOperand(i), RHS));
|
Operands.push_back(getUDivExpr(AR->getOperand(i), RHS));
|
||||||
return getAddRecExpr(Operands, AR->getLoop());
|
return getAddRecExpr(Operands, AR->getLoop());
|
||||||
}
|
}
|
||||||
// (A*B)/C --> A*(B/C) if safe and B/C can be folded.
|
// (A*B)/C --> A*(B/C) if safe and B/C can be folded.
|
||||||
if (const SCEVMulExpr *M = dyn_cast<SCEVMulExpr>(LHS)) {
|
if (const SCEVMulExpr *M = dyn_cast<SCEVMulExpr>(LHS)) {
|
||||||
std::vector<SCEVHandle> Operands;
|
SmallVector<SCEVHandle, 4> Operands;
|
||||||
for (unsigned i = 0, e = M->getNumOperands(); i != e; ++i)
|
for (unsigned i = 0, e = M->getNumOperands(); i != e; ++i)
|
||||||
Operands.push_back(getZeroExtendExpr(M->getOperand(i), ExtTy));
|
Operands.push_back(getZeroExtendExpr(M->getOperand(i), ExtTy));
|
||||||
if (getZeroExtendExpr(M, ExtTy) == getMulExpr(Operands))
|
if (getZeroExtendExpr(M, ExtTy) == getMulExpr(Operands))
|
||||||
@ -1489,7 +1489,9 @@ SCEVHandle ScalarEvolution::getUDivExpr(const SCEVHandle &LHS,
|
|||||||
SCEVHandle Op = M->getOperand(i);
|
SCEVHandle Op = M->getOperand(i);
|
||||||
SCEVHandle Div = getUDivExpr(Op, RHSC);
|
SCEVHandle Div = getUDivExpr(Op, RHSC);
|
||||||
if (!isa<SCEVUDivExpr>(Div) && getMulExpr(Div, RHSC) == Op) {
|
if (!isa<SCEVUDivExpr>(Div) && getMulExpr(Div, RHSC) == Op) {
|
||||||
Operands = M->getOperands();
|
const SmallVectorImpl<SCEVHandle> &MOperands = M->getOperands();
|
||||||
|
Operands = SmallVector<SCEVHandle, 4>(MOperands.begin(),
|
||||||
|
MOperands.end());
|
||||||
Operands[i] = Div;
|
Operands[i] = Div;
|
||||||
return getMulExpr(Operands);
|
return getMulExpr(Operands);
|
||||||
}
|
}
|
||||||
@ -1497,7 +1499,7 @@ SCEVHandle ScalarEvolution::getUDivExpr(const SCEVHandle &LHS,
|
|||||||
}
|
}
|
||||||
// (A+B)/C --> (A/C + B/C) if safe and A/C and B/C can be folded.
|
// (A+B)/C --> (A/C + B/C) if safe and A/C and B/C can be folded.
|
||||||
if (const SCEVAddRecExpr *A = dyn_cast<SCEVAddRecExpr>(LHS)) {
|
if (const SCEVAddRecExpr *A = dyn_cast<SCEVAddRecExpr>(LHS)) {
|
||||||
std::vector<SCEVHandle> Operands;
|
SmallVector<SCEVHandle, 4> Operands;
|
||||||
for (unsigned i = 0, e = A->getNumOperands(); i != e; ++i)
|
for (unsigned i = 0, e = A->getNumOperands(); i != e; ++i)
|
||||||
Operands.push_back(getZeroExtendExpr(A->getOperand(i), ExtTy));
|
Operands.push_back(getZeroExtendExpr(A->getOperand(i), ExtTy));
|
||||||
if (getZeroExtendExpr(A, ExtTy) == getAddExpr(Operands)) {
|
if (getZeroExtendExpr(A, ExtTy) == getAddExpr(Operands)) {
|
||||||
@ -1531,7 +1533,7 @@ SCEVHandle ScalarEvolution::getUDivExpr(const SCEVHandle &LHS,
|
|||||||
/// Simplify the expression as much as possible.
|
/// Simplify the expression as much as possible.
|
||||||
SCEVHandle ScalarEvolution::getAddRecExpr(const SCEVHandle &Start,
|
SCEVHandle ScalarEvolution::getAddRecExpr(const SCEVHandle &Start,
|
||||||
const SCEVHandle &Step, const Loop *L) {
|
const SCEVHandle &Step, const Loop *L) {
|
||||||
std::vector<SCEVHandle> Operands;
|
SmallVector<SCEVHandle, 4> Operands;
|
||||||
Operands.push_back(Start);
|
Operands.push_back(Start);
|
||||||
if (const SCEVAddRecExpr *StepChrec = dyn_cast<SCEVAddRecExpr>(Step))
|
if (const SCEVAddRecExpr *StepChrec = dyn_cast<SCEVAddRecExpr>(Step))
|
||||||
if (StepChrec->getLoop() == L) {
|
if (StepChrec->getLoop() == L) {
|
||||||
@ -1546,7 +1548,7 @@ SCEVHandle ScalarEvolution::getAddRecExpr(const SCEVHandle &Start,
|
|||||||
|
|
||||||
/// getAddRecExpr - Get an add recurrence expression for the specified loop.
|
/// getAddRecExpr - Get an add recurrence expression for the specified loop.
|
||||||
/// Simplify the expression as much as possible.
|
/// Simplify the expression as much as possible.
|
||||||
SCEVHandle ScalarEvolution::getAddRecExpr(std::vector<SCEVHandle> &Operands,
|
SCEVHandle ScalarEvolution::getAddRecExpr(SmallVectorImpl<SCEVHandle> &Operands,
|
||||||
const Loop *L) {
|
const Loop *L) {
|
||||||
if (Operands.size() == 1) return Operands[0];
|
if (Operands.size() == 1) return Operands[0];
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
@ -1565,8 +1567,8 @@ SCEVHandle ScalarEvolution::getAddRecExpr(std::vector<SCEVHandle> &Operands,
|
|||||||
if (const SCEVAddRecExpr *NestedAR = dyn_cast<SCEVAddRecExpr>(Operands[0])) {
|
if (const SCEVAddRecExpr *NestedAR = dyn_cast<SCEVAddRecExpr>(Operands[0])) {
|
||||||
const Loop* NestedLoop = NestedAR->getLoop();
|
const Loop* NestedLoop = NestedAR->getLoop();
|
||||||
if (L->getLoopDepth() < NestedLoop->getLoopDepth()) {
|
if (L->getLoopDepth() < NestedLoop->getLoopDepth()) {
|
||||||
std::vector<SCEVHandle> NestedOperands(NestedAR->op_begin(),
|
SmallVector<SCEVHandle, 4> NestedOperands(NestedAR->op_begin(),
|
||||||
NestedAR->op_end());
|
NestedAR->op_end());
|
||||||
SCEVHandle NestedARHandle(NestedAR);
|
SCEVHandle NestedARHandle(NestedAR);
|
||||||
Operands[0] = NestedAR->getStart();
|
Operands[0] = NestedAR->getStart();
|
||||||
NestedOperands[0] = getAddRecExpr(Operands, L);
|
NestedOperands[0] = getAddRecExpr(Operands, L);
|
||||||
@ -1582,13 +1584,14 @@ SCEVHandle ScalarEvolution::getAddRecExpr(std::vector<SCEVHandle> &Operands,
|
|||||||
|
|
||||||
SCEVHandle ScalarEvolution::getSMaxExpr(const SCEVHandle &LHS,
|
SCEVHandle ScalarEvolution::getSMaxExpr(const SCEVHandle &LHS,
|
||||||
const SCEVHandle &RHS) {
|
const SCEVHandle &RHS) {
|
||||||
std::vector<SCEVHandle> Ops;
|
SmallVector<SCEVHandle, 2> Ops;
|
||||||
Ops.push_back(LHS);
|
Ops.push_back(LHS);
|
||||||
Ops.push_back(RHS);
|
Ops.push_back(RHS);
|
||||||
return getSMaxExpr(Ops);
|
return getSMaxExpr(Ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCEVHandle ScalarEvolution::getSMaxExpr(std::vector<SCEVHandle> Ops) {
|
SCEVHandle
|
||||||
|
ScalarEvolution::getSMaxExpr(SmallVectorImpl<SCEVHandle> &Ops) {
|
||||||
assert(!Ops.empty() && "Cannot get empty smax!");
|
assert(!Ops.empty() && "Cannot get empty smax!");
|
||||||
if (Ops.size() == 1) return Ops[0];
|
if (Ops.size() == 1) return Ops[0];
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
@ -1668,13 +1671,14 @@ SCEVHandle ScalarEvolution::getSMaxExpr(std::vector<SCEVHandle> Ops) {
|
|||||||
|
|
||||||
SCEVHandle ScalarEvolution::getUMaxExpr(const SCEVHandle &LHS,
|
SCEVHandle ScalarEvolution::getUMaxExpr(const SCEVHandle &LHS,
|
||||||
const SCEVHandle &RHS) {
|
const SCEVHandle &RHS) {
|
||||||
std::vector<SCEVHandle> Ops;
|
SmallVector<SCEVHandle, 2> Ops;
|
||||||
Ops.push_back(LHS);
|
Ops.push_back(LHS);
|
||||||
Ops.push_back(RHS);
|
Ops.push_back(RHS);
|
||||||
return getUMaxExpr(Ops);
|
return getUMaxExpr(Ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCEVHandle ScalarEvolution::getUMaxExpr(std::vector<SCEVHandle> Ops) {
|
SCEVHandle
|
||||||
|
ScalarEvolution::getUMaxExpr(SmallVectorImpl<SCEVHandle> &Ops) {
|
||||||
assert(!Ops.empty() && "Cannot get empty umax!");
|
assert(!Ops.empty() && "Cannot get empty umax!");
|
||||||
if (Ops.size() == 1) return Ops[0];
|
if (Ops.size() == 1) return Ops[0];
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
@ -2040,7 +2044,7 @@ SCEVHandle ScalarEvolution::createNodeForPHI(PHINode *PN) {
|
|||||||
|
|
||||||
if (FoundIndex != Add->getNumOperands()) {
|
if (FoundIndex != Add->getNumOperands()) {
|
||||||
// Create an add with everything but the specified operand.
|
// Create an add with everything but the specified operand.
|
||||||
std::vector<SCEVHandle> Ops;
|
SmallVector<SCEVHandle, 8> Ops;
|
||||||
for (unsigned i = 0, e = Add->getNumOperands(); i != e; ++i)
|
for (unsigned i = 0, e = Add->getNumOperands(); i != e; ++i)
|
||||||
if (i != FoundIndex)
|
if (i != FoundIndex)
|
||||||
Ops.push_back(Add->getOperand(i));
|
Ops.push_back(Add->getOperand(i));
|
||||||
@ -3074,7 +3078,7 @@ SCEVHandle ScalarEvolution::getSCEVAtScope(const SCEV *V, const Loop *L) {
|
|||||||
if (OpAtScope != Comm->getOperand(i)) {
|
if (OpAtScope != Comm->getOperand(i)) {
|
||||||
// Okay, at least one of these operands is loop variant but might be
|
// Okay, at least one of these operands is loop variant but might be
|
||||||
// foldable. Build a new instance of the folded commutative expression.
|
// foldable. Build a new instance of the folded commutative expression.
|
||||||
std::vector<SCEVHandle> NewOps(Comm->op_begin(), Comm->op_begin()+i);
|
SmallVector<SCEVHandle, 8> NewOps(Comm->op_begin(), Comm->op_begin()+i);
|
||||||
NewOps.push_back(OpAtScope);
|
NewOps.push_back(OpAtScope);
|
||||||
|
|
||||||
for (++i; i != e; ++i) {
|
for (++i; i != e; ++i) {
|
||||||
@ -3611,7 +3615,7 @@ SCEVHandle SCEVAddRecExpr::getNumIterationsInRange(ConstantRange Range,
|
|||||||
// If the start is a non-zero constant, shift the range to simplify things.
|
// If the start is a non-zero constant, shift the range to simplify things.
|
||||||
if (const SCEVConstant *SC = dyn_cast<SCEVConstant>(getStart()))
|
if (const SCEVConstant *SC = dyn_cast<SCEVConstant>(getStart()))
|
||||||
if (!SC->getValue()->isZero()) {
|
if (!SC->getValue()->isZero()) {
|
||||||
std::vector<SCEVHandle> Operands(op_begin(), op_end());
|
SmallVector<SCEVHandle, 4> Operands(op_begin(), op_end());
|
||||||
Operands[0] = SE.getIntegerSCEV(0, SC->getType());
|
Operands[0] = SE.getIntegerSCEV(0, SC->getType());
|
||||||
SCEVHandle Shifted = SE.getAddRecExpr(Operands, getLoop());
|
SCEVHandle Shifted = SE.getAddRecExpr(Operands, getLoop());
|
||||||
if (const SCEVAddRecExpr *ShiftedAddRec =
|
if (const SCEVAddRecExpr *ShiftedAddRec =
|
||||||
@ -3672,7 +3676,7 @@ SCEVHandle SCEVAddRecExpr::getNumIterationsInRange(ConstantRange Range,
|
|||||||
// quadratic equation to solve it. To do this, we must frame our problem in
|
// quadratic equation to solve it. To do this, we must frame our problem in
|
||||||
// terms of figuring out when zero is crossed, instead of when
|
// terms of figuring out when zero is crossed, instead of when
|
||||||
// Range.getUpper() is crossed.
|
// Range.getUpper() is crossed.
|
||||||
std::vector<SCEVHandle> NewOps(op_begin(), op_end());
|
SmallVector<SCEVHandle, 4> NewOps(op_begin(), op_end());
|
||||||
NewOps[0] = SE.getNegativeSCEV(SE.getConstant(Range.getUpper()));
|
NewOps[0] = SE.getNegativeSCEV(SE.getConstant(Range.getUpper()));
|
||||||
SCEVHandle NewAddRec = SE.getAddRecExpr(NewOps, getLoop());
|
SCEVHandle NewAddRec = SE.getAddRecExpr(NewOps, getLoop());
|
||||||
|
|
||||||
|
@ -182,7 +182,8 @@ static bool FactorOutConstant(SCEVHandle &S,
|
|||||||
if (const SCEVMulExpr *M = dyn_cast<SCEVMulExpr>(S))
|
if (const SCEVMulExpr *M = dyn_cast<SCEVMulExpr>(S))
|
||||||
if (const SCEVConstant *C = dyn_cast<SCEVConstant>(M->getOperand(0)))
|
if (const SCEVConstant *C = dyn_cast<SCEVConstant>(M->getOperand(0)))
|
||||||
if (!C->getValue()->getValue().srem(Factor)) {
|
if (!C->getValue()->getValue().srem(Factor)) {
|
||||||
std::vector<SCEVHandle> NewMulOps(M->getOperands());
|
const SmallVectorImpl<SCEVHandle> &MOperands = M->getOperands();
|
||||||
|
SmallVector<SCEVHandle, 4> NewMulOps(MOperands.begin(), MOperands.end());
|
||||||
NewMulOps[0] =
|
NewMulOps[0] =
|
||||||
SE.getConstant(C->getValue()->getValue().sdiv(Factor));
|
SE.getConstant(C->getValue()->getValue().sdiv(Factor));
|
||||||
S = SE.getMulExpr(NewMulOps);
|
S = SE.getMulExpr(NewMulOps);
|
||||||
@ -239,7 +240,7 @@ Value *SCEVExpander::expandAddToGEP(const SCEVHandle *op_begin,
|
|||||||
Value *V) {
|
Value *V) {
|
||||||
const Type *ElTy = PTy->getElementType();
|
const Type *ElTy = PTy->getElementType();
|
||||||
SmallVector<Value *, 4> GepIndices;
|
SmallVector<Value *, 4> GepIndices;
|
||||||
std::vector<SCEVHandle> Ops(op_begin, op_end);
|
SmallVector<SCEVHandle, 8> Ops(op_begin, op_end);
|
||||||
bool AnyNonZeroIndices = false;
|
bool AnyNonZeroIndices = false;
|
||||||
|
|
||||||
// Decend down the pointer's type and attempt to convert the other
|
// Decend down the pointer's type and attempt to convert the other
|
||||||
@ -250,8 +251,8 @@ Value *SCEVExpander::expandAddToGEP(const SCEVHandle *op_begin,
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
APInt ElSize = APInt(SE.getTypeSizeInBits(Ty),
|
APInt ElSize = APInt(SE.getTypeSizeInBits(Ty),
|
||||||
ElTy->isSized() ? SE.TD->getTypeAllocSize(ElTy) : 0);
|
ElTy->isSized() ? SE.TD->getTypeAllocSize(ElTy) : 0);
|
||||||
std::vector<SCEVHandle> NewOps;
|
SmallVector<SCEVHandle, 8> NewOps;
|
||||||
std::vector<SCEVHandle> ScaledOps;
|
SmallVector<SCEVHandle, 8> ScaledOps;
|
||||||
for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
|
||||||
// Split AddRecs up into parts as either of the parts may be usable
|
// Split AddRecs up into parts as either of the parts may be usable
|
||||||
// without the other.
|
// without the other.
|
||||||
@ -365,7 +366,7 @@ Value *SCEVExpander::visitAddExpr(const SCEVAddExpr *S) {
|
|||||||
// comments on expandAddToGEP for details.
|
// comments on expandAddToGEP for details.
|
||||||
if (SE.TD)
|
if (SE.TD)
|
||||||
if (const PointerType *PTy = dyn_cast<PointerType>(V->getType())) {
|
if (const PointerType *PTy = dyn_cast<PointerType>(V->getType())) {
|
||||||
const std::vector<SCEVHandle> &Ops = S->getOperands();
|
const SmallVectorImpl<SCEVHandle> &Ops = S->getOperands();
|
||||||
return expandAddToGEP(&Ops[0], &Ops[Ops.size() - 1],
|
return expandAddToGEP(&Ops[0], &Ops[Ops.size() - 1],
|
||||||
PTy, Ty, V);
|
PTy, Ty, V);
|
||||||
}
|
}
|
||||||
@ -432,7 +433,7 @@ static void ExposePointerBase(SCEVHandle &Base, SCEVHandle &Rest,
|
|||||||
}
|
}
|
||||||
if (const SCEVAddExpr *A = dyn_cast<SCEVAddExpr>(Base)) {
|
if (const SCEVAddExpr *A = dyn_cast<SCEVAddExpr>(Base)) {
|
||||||
Base = A->getOperand(A->getNumOperands()-1);
|
Base = A->getOperand(A->getNumOperands()-1);
|
||||||
std::vector<SCEVHandle> NewAddOps(A->op_begin(), A->op_end());
|
SmallVector<SCEVHandle, 8> NewAddOps(A->op_begin(), A->op_end());
|
||||||
NewAddOps.back() = Rest;
|
NewAddOps.back() = Rest;
|
||||||
Rest = SE.getAddExpr(NewAddOps);
|
Rest = SE.getAddExpr(NewAddOps);
|
||||||
ExposePointerBase(Base, Rest, SE);
|
ExposePointerBase(Base, Rest, SE);
|
||||||
@ -473,7 +474,8 @@ Value *SCEVExpander::visitAddRecExpr(const SCEVAddRecExpr *S) {
|
|||||||
|
|
||||||
// {X,+,F} --> X + {0,+,F}
|
// {X,+,F} --> X + {0,+,F}
|
||||||
if (!S->getStart()->isZero()) {
|
if (!S->getStart()->isZero()) {
|
||||||
std::vector<SCEVHandle> NewOps(S->getOperands());
|
const SmallVectorImpl<SCEVHandle> &SOperands = S->getOperands();
|
||||||
|
SmallVector<SCEVHandle, 4> NewOps(SOperands.begin(), SOperands.end());
|
||||||
NewOps[0] = SE.getIntegerSCEV(0, Ty);
|
NewOps[0] = SE.getIntegerSCEV(0, Ty);
|
||||||
SCEVHandle Rest = SE.getAddRecExpr(NewOps, L);
|
SCEVHandle Rest = SE.getAddRecExpr(NewOps, L);
|
||||||
|
|
||||||
|
@ -592,7 +592,7 @@ static void MoveLoopVariantsToImmediateField(SCEVHandle &Val, SCEVHandle &Imm,
|
|||||||
if (Val->isLoopInvariant(L)) return; // Nothing to do.
|
if (Val->isLoopInvariant(L)) return; // Nothing to do.
|
||||||
|
|
||||||
if (const SCEVAddExpr *SAE = dyn_cast<SCEVAddExpr>(Val)) {
|
if (const SCEVAddExpr *SAE = dyn_cast<SCEVAddExpr>(Val)) {
|
||||||
std::vector<SCEVHandle> NewOps;
|
SmallVector<SCEVHandle, 4> NewOps;
|
||||||
NewOps.reserve(SAE->getNumOperands());
|
NewOps.reserve(SAE->getNumOperands());
|
||||||
|
|
||||||
for (unsigned i = 0; i != SAE->getNumOperands(); ++i)
|
for (unsigned i = 0; i != SAE->getNumOperands(); ++i)
|
||||||
@ -613,7 +613,7 @@ static void MoveLoopVariantsToImmediateField(SCEVHandle &Val, SCEVHandle &Imm,
|
|||||||
SCEVHandle Start = SARE->getStart();
|
SCEVHandle Start = SARE->getStart();
|
||||||
MoveLoopVariantsToImmediateField(Start, Imm, L, SE);
|
MoveLoopVariantsToImmediateField(Start, Imm, L, SE);
|
||||||
|
|
||||||
std::vector<SCEVHandle> Ops(SARE->op_begin(), SARE->op_end());
|
SmallVector<SCEVHandle, 4> Ops(SARE->op_begin(), SARE->op_end());
|
||||||
Ops[0] = Start;
|
Ops[0] = Start;
|
||||||
Val = SE->getAddRecExpr(Ops, SARE->getLoop());
|
Val = SE->getAddRecExpr(Ops, SARE->getLoop());
|
||||||
} else {
|
} else {
|
||||||
@ -633,7 +633,7 @@ static void MoveImmediateValues(const TargetLowering *TLI,
|
|||||||
bool isAddress, Loop *L,
|
bool isAddress, Loop *L,
|
||||||
ScalarEvolution *SE) {
|
ScalarEvolution *SE) {
|
||||||
if (const SCEVAddExpr *SAE = dyn_cast<SCEVAddExpr>(Val)) {
|
if (const SCEVAddExpr *SAE = dyn_cast<SCEVAddExpr>(Val)) {
|
||||||
std::vector<SCEVHandle> NewOps;
|
SmallVector<SCEVHandle, 4> NewOps;
|
||||||
NewOps.reserve(SAE->getNumOperands());
|
NewOps.reserve(SAE->getNumOperands());
|
||||||
|
|
||||||
for (unsigned i = 0; i != SAE->getNumOperands(); ++i) {
|
for (unsigned i = 0; i != SAE->getNumOperands(); ++i) {
|
||||||
@ -660,7 +660,7 @@ static void MoveImmediateValues(const TargetLowering *TLI,
|
|||||||
MoveImmediateValues(TLI, AccessTy, Start, Imm, isAddress, L, SE);
|
MoveImmediateValues(TLI, AccessTy, Start, Imm, isAddress, L, SE);
|
||||||
|
|
||||||
if (Start != SARE->getStart()) {
|
if (Start != SARE->getStart()) {
|
||||||
std::vector<SCEVHandle> Ops(SARE->op_begin(), SARE->op_end());
|
SmallVector<SCEVHandle, 4> Ops(SARE->op_begin(), SARE->op_end());
|
||||||
Ops[0] = Start;
|
Ops[0] = Start;
|
||||||
Val = SE->getAddRecExpr(Ops, SARE->getLoop());
|
Val = SE->getAddRecExpr(Ops, SARE->getLoop());
|
||||||
}
|
}
|
||||||
@ -717,7 +717,7 @@ static void MoveImmediateValues(const TargetLowering *TLI,
|
|||||||
/// SeparateSubExprs - Decompose Expr into all of the subexpressions that are
|
/// SeparateSubExprs - Decompose Expr into all of the subexpressions that are
|
||||||
/// added together. This is used to reassociate common addition subexprs
|
/// added together. This is used to reassociate common addition subexprs
|
||||||
/// together for maximal sharing when rewriting bases.
|
/// together for maximal sharing when rewriting bases.
|
||||||
static void SeparateSubExprs(std::vector<SCEVHandle> &SubExprs,
|
static void SeparateSubExprs(SmallVector<SCEVHandle, 16> &SubExprs,
|
||||||
SCEVHandle Expr,
|
SCEVHandle Expr,
|
||||||
ScalarEvolution *SE) {
|
ScalarEvolution *SE) {
|
||||||
if (const SCEVAddExpr *AE = dyn_cast<SCEVAddExpr>(Expr)) {
|
if (const SCEVAddExpr *AE = dyn_cast<SCEVAddExpr>(Expr)) {
|
||||||
@ -729,7 +729,7 @@ static void SeparateSubExprs(std::vector<SCEVHandle> &SubExprs,
|
|||||||
SubExprs.push_back(Expr);
|
SubExprs.push_back(Expr);
|
||||||
} else {
|
} else {
|
||||||
// Compute the addrec with zero as its base.
|
// Compute the addrec with zero as its base.
|
||||||
std::vector<SCEVHandle> Ops(SARE->op_begin(), SARE->op_end());
|
SmallVector<SCEVHandle, 4> Ops(SARE->op_begin(), SARE->op_end());
|
||||||
Ops[0] = Zero; // Start with zero base.
|
Ops[0] = Zero; // Start with zero base.
|
||||||
SubExprs.push_back(SE->getAddRecExpr(Ops, SARE->getLoop()));
|
SubExprs.push_back(SE->getAddRecExpr(Ops, SARE->getLoop()));
|
||||||
|
|
||||||
@ -783,9 +783,9 @@ RemoveCommonExpressionsFromUseBases(std::vector<BasedUser> &Uses,
|
|||||||
|
|
||||||
// UniqueSubExprs - Keep track of all of the subexpressions we see in the
|
// UniqueSubExprs - Keep track of all of the subexpressions we see in the
|
||||||
// order we see them.
|
// order we see them.
|
||||||
std::vector<SCEVHandle> UniqueSubExprs;
|
SmallVector<SCEVHandle, 16> UniqueSubExprs;
|
||||||
|
|
||||||
std::vector<SCEVHandle> SubExprs;
|
SmallVector<SCEVHandle, 16> SubExprs;
|
||||||
unsigned NumUsesInsideLoop = 0;
|
unsigned NumUsesInsideLoop = 0;
|
||||||
for (unsigned i = 0; i != NumUses; ++i) {
|
for (unsigned i = 0; i != NumUses; ++i) {
|
||||||
// If the user is outside the loop, just ignore it for base computation.
|
// If the user is outside the loop, just ignore it for base computation.
|
||||||
|
Loading…
Reference in New Issue
Block a user