forked from OSchip/llvm-project
Revert 98755, which may be causing trouble.
llvm-svn: 98762
This commit is contained in:
parent
6221720599
commit
d2abecaeea
|
@ -180,27 +180,25 @@ namespace llvm {
|
||||||
///
|
///
|
||||||
class SCEVNAryExpr : public SCEV {
|
class SCEVNAryExpr : public SCEV {
|
||||||
protected:
|
protected:
|
||||||
// Since SCEVs are immutable, ScalarEvolution allocates operand
|
SmallVector<const SCEV *, 8> Operands;
|
||||||
// arrays with its SCEVAllocator, so this class just needs a simple
|
|
||||||
// pointer rather than a more elaborate vector-like data structure.
|
|
||||||
// This also avoids the need for a non-trivial destructor.
|
|
||||||
const SCEV *const *Operands;
|
|
||||||
size_t NumOperands;
|
|
||||||
|
|
||||||
SCEVNAryExpr(const FoldingSetNodeID &ID,
|
SCEVNAryExpr(const FoldingSetNodeID &ID,
|
||||||
enum SCEVTypes T, const SCEV *const *O, size_t N)
|
enum SCEVTypes T, const SmallVectorImpl<const SCEV *> &ops)
|
||||||
: SCEV(ID, T), Operands(O), NumOperands(N) {}
|
: SCEV(ID, T), Operands(ops.begin(), ops.end()) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
size_t getNumOperands() const { return NumOperands; }
|
unsigned getNumOperands() const { return (unsigned)Operands.size(); }
|
||||||
const SCEV *getOperand(unsigned i) const {
|
const SCEV *getOperand(unsigned i) const {
|
||||||
assert(i < NumOperands && "Operand index out of range!");
|
assert(i < Operands.size() && "Operand index out of range!");
|
||||||
return Operands[i];
|
return Operands[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef const SCEV *const *op_iterator;
|
const SmallVectorImpl<const SCEV *> &getOperands() const {
|
||||||
op_iterator op_begin() const { return Operands; }
|
return Operands;
|
||||||
op_iterator op_end() const { return Operands + NumOperands; }
|
}
|
||||||
|
typedef SmallVectorImpl<const SCEV *>::const_iterator op_iterator;
|
||||||
|
op_iterator op_begin() const { return Operands.begin(); }
|
||||||
|
op_iterator op_end() const { return Operands.end(); }
|
||||||
|
|
||||||
virtual bool isLoopInvariant(const Loop *L) const {
|
virtual bool isLoopInvariant(const Loop *L) const {
|
||||||
for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
|
for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
|
||||||
|
@ -264,8 +262,8 @@ namespace llvm {
|
||||||
protected:
|
protected:
|
||||||
SCEVCommutativeExpr(const FoldingSetNodeID &ID,
|
SCEVCommutativeExpr(const FoldingSetNodeID &ID,
|
||||||
enum SCEVTypes T,
|
enum SCEVTypes T,
|
||||||
const SCEV *const *O, size_t N)
|
const SmallVectorImpl<const SCEV *> &ops)
|
||||||
: SCEVNAryExpr(ID, T, O, N) {}
|
: SCEVNAryExpr(ID, T, ops) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual const char *getOperationStr() const = 0;
|
virtual const char *getOperationStr() const = 0;
|
||||||
|
@ -290,8 +288,8 @@ namespace llvm {
|
||||||
friend class ScalarEvolution;
|
friend class ScalarEvolution;
|
||||||
|
|
||||||
SCEVAddExpr(const FoldingSetNodeID &ID,
|
SCEVAddExpr(const FoldingSetNodeID &ID,
|
||||||
const SCEV *const *O, size_t N)
|
const SmallVectorImpl<const SCEV *> &ops)
|
||||||
: SCEVCommutativeExpr(ID, scAddExpr, O, N) {
|
: SCEVCommutativeExpr(ID, scAddExpr, ops) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -318,8 +316,8 @@ namespace llvm {
|
||||||
friend class ScalarEvolution;
|
friend class ScalarEvolution;
|
||||||
|
|
||||||
SCEVMulExpr(const FoldingSetNodeID &ID,
|
SCEVMulExpr(const FoldingSetNodeID &ID,
|
||||||
const SCEV *const *O, size_t N)
|
const SmallVectorImpl<const SCEV *> &ops)
|
||||||
: SCEVCommutativeExpr(ID, scMulExpr, O, N) {
|
: SCEVCommutativeExpr(ID, scMulExpr, ops) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -392,9 +390,9 @@ namespace llvm {
|
||||||
const Loop *L;
|
const Loop *L;
|
||||||
|
|
||||||
SCEVAddRecExpr(const FoldingSetNodeID &ID,
|
SCEVAddRecExpr(const FoldingSetNodeID &ID,
|
||||||
const SCEV *const *O, size_t N, const Loop *l)
|
const SmallVectorImpl<const SCEV *> &ops, const Loop *l)
|
||||||
: SCEVNAryExpr(ID, scAddRecExpr, O, N), L(l) {
|
: SCEVNAryExpr(ID, scAddRecExpr, ops), L(l) {
|
||||||
for (size_t i = 0, e = NumOperands; i != e; ++i)
|
for (size_t i = 0, e = Operands.size(); i != e; ++i)
|
||||||
assert(Operands[i]->isLoopInvariant(l) &&
|
assert(Operands[i]->isLoopInvariant(l) &&
|
||||||
"Operands of AddRec must be loop-invariant!");
|
"Operands of AddRec must be loop-invariant!");
|
||||||
}
|
}
|
||||||
|
@ -474,8 +472,8 @@ namespace llvm {
|
||||||
friend class ScalarEvolution;
|
friend class ScalarEvolution;
|
||||||
|
|
||||||
SCEVSMaxExpr(const FoldingSetNodeID &ID,
|
SCEVSMaxExpr(const FoldingSetNodeID &ID,
|
||||||
const SCEV *const *O, size_t N)
|
const SmallVectorImpl<const SCEV *> &ops)
|
||||||
: SCEVCommutativeExpr(ID, scSMaxExpr, O, N) {
|
: SCEVCommutativeExpr(ID, scSMaxExpr, ops) {
|
||||||
// Max never overflows.
|
// Max never overflows.
|
||||||
setHasNoUnsignedWrap(true);
|
setHasNoUnsignedWrap(true);
|
||||||
setHasNoSignedWrap(true);
|
setHasNoSignedWrap(true);
|
||||||
|
@ -499,8 +497,8 @@ namespace llvm {
|
||||||
friend class ScalarEvolution;
|
friend class ScalarEvolution;
|
||||||
|
|
||||||
SCEVUMaxExpr(const FoldingSetNodeID &ID,
|
SCEVUMaxExpr(const FoldingSetNodeID &ID,
|
||||||
const SCEV *const *O, size_t N)
|
const SmallVectorImpl<const SCEV *> &ops)
|
||||||
: SCEVCommutativeExpr(ID, scUMaxExpr, O, N) {
|
: SCEVCommutativeExpr(ID, scUMaxExpr, ops) {
|
||||||
// Max never overflows.
|
// Max never overflows.
|
||||||
setHasNoUnsignedWrap(true);
|
setHasNoUnsignedWrap(true);
|
||||||
setHasNoSignedWrap(true);
|
setHasNoSignedWrap(true);
|
||||||
|
|
|
@ -248,10 +248,10 @@ void SCEVSignExtendExpr::print(raw_ostream &OS) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCEVCommutativeExpr::print(raw_ostream &OS) const {
|
void SCEVCommutativeExpr::print(raw_ostream &OS) const {
|
||||||
assert(NumOperands > 1 && "This plus expr shouldn't exist!");
|
assert(Operands.size() > 1 && "This plus expr shouldn't exist!");
|
||||||
const char *OpStr = getOperationStr();
|
const char *OpStr = getOperationStr();
|
||||||
OS << "(" << *Operands[0];
|
OS << "(" << *Operands[0];
|
||||||
for (unsigned i = 1, e = NumOperands; i != e; ++i)
|
for (unsigned i = 1, e = Operands.size(); i != e; ++i)
|
||||||
OS << OpStr << *Operands[i];
|
OS << OpStr << *Operands[i];
|
||||||
OS << ")";
|
OS << ")";
|
||||||
}
|
}
|
||||||
|
@ -329,7 +329,7 @@ SCEVAddRecExpr::properlyDominates(BasicBlock *BB, DominatorTree *DT) const {
|
||||||
|
|
||||||
void SCEVAddRecExpr::print(raw_ostream &OS) const {
|
void SCEVAddRecExpr::print(raw_ostream &OS) const {
|
||||||
OS << "{" << *Operands[0];
|
OS << "{" << *Operands[0];
|
||||||
for (unsigned i = 1, e = NumOperands; i != e; ++i)
|
for (unsigned i = 1, e = Operands.size(); i != e; ++i)
|
||||||
OS << ",+," << *Operands[i];
|
OS << ",+," << *Operands[i];
|
||||||
OS << "}<";
|
OS << "}<";
|
||||||
WriteAsOperand(OS, L->getHeader(), /*PrintType=*/false);
|
WriteAsOperand(OS, L->getHeader(), /*PrintType=*/false);
|
||||||
|
@ -1202,23 +1202,23 @@ static bool
|
||||||
CollectAddOperandsWithScales(DenseMap<const SCEV *, APInt> &M,
|
CollectAddOperandsWithScales(DenseMap<const SCEV *, APInt> &M,
|
||||||
SmallVector<const SCEV *, 8> &NewOps,
|
SmallVector<const SCEV *, 8> &NewOps,
|
||||||
APInt &AccumulatedConstant,
|
APInt &AccumulatedConstant,
|
||||||
const SCEV *const *Ops, size_t NumOperands,
|
const SmallVectorImpl<const SCEV *> &Ops,
|
||||||
const APInt &Scale,
|
const APInt &Scale,
|
||||||
ScalarEvolution &SE) {
|
ScalarEvolution &SE) {
|
||||||
bool Interesting = false;
|
bool Interesting = false;
|
||||||
|
|
||||||
// Iterate over the add operands.
|
// Iterate over the add operands.
|
||||||
for (unsigned i = 0, e = NumOperands; i != e; ++i) {
|
for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
|
||||||
const SCEVMulExpr *Mul = dyn_cast<SCEVMulExpr>(Ops[i]);
|
const SCEVMulExpr *Mul = dyn_cast<SCEVMulExpr>(Ops[i]);
|
||||||
if (Mul && isa<SCEVConstant>(Mul->getOperand(0))) {
|
if (Mul && isa<SCEVConstant>(Mul->getOperand(0))) {
|
||||||
APInt NewScale =
|
APInt NewScale =
|
||||||
Scale * cast<SCEVConstant>(Mul->getOperand(0))->getValue()->getValue();
|
Scale * cast<SCEVConstant>(Mul->getOperand(0))->getValue()->getValue();
|
||||||
if (Mul->getNumOperands() == 2 && isa<SCEVAddExpr>(Mul->getOperand(1))) {
|
if (Mul->getNumOperands() == 2 && isa<SCEVAddExpr>(Mul->getOperand(1))) {
|
||||||
// A multiplication of a constant with another add; recurse.
|
// A multiplication of a constant with another add; recurse.
|
||||||
const SCEVAddExpr *Add = cast<SCEVAddExpr>(Mul->getOperand(1));
|
|
||||||
Interesting |=
|
Interesting |=
|
||||||
CollectAddOperandsWithScales(M, NewOps, AccumulatedConstant,
|
CollectAddOperandsWithScales(M, NewOps, AccumulatedConstant,
|
||||||
Add->op_begin(), Add->getNumOperands(),
|
cast<SCEVAddExpr>(Mul->getOperand(1))
|
||||||
|
->getOperands(),
|
||||||
NewScale, SE);
|
NewScale, SE);
|
||||||
} else {
|
} else {
|
||||||
// A multiplication of a constant with some other value. Update
|
// A multiplication of a constant with some other value. Update
|
||||||
|
@ -1427,8 +1427,7 @@ const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl<const SCEV *> &Ops,
|
||||||
SmallVector<const SCEV *, 8> NewOps;
|
SmallVector<const SCEV *, 8> NewOps;
|
||||||
APInt AccumulatedConstant(BitWidth, 0);
|
APInt AccumulatedConstant(BitWidth, 0);
|
||||||
if (CollectAddOperandsWithScales(M, NewOps, AccumulatedConstant,
|
if (CollectAddOperandsWithScales(M, NewOps, AccumulatedConstant,
|
||||||
Ops.data(), Ops.size(),
|
Ops, APInt(BitWidth, 1), *this)) {
|
||||||
APInt(BitWidth, 1), *this)) {
|
|
||||||
// Some interesting folding opportunity is present, so its worthwhile to
|
// Some interesting folding opportunity is present, so its worthwhile to
|
||||||
// re-generate the operands list. Group the operands by constant scale,
|
// re-generate the operands list. Group the operands by constant scale,
|
||||||
// to avoid multiplying by the same constant scale multiple times.
|
// to avoid multiplying by the same constant scale multiple times.
|
||||||
|
@ -1613,9 +1612,7 @@ const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl<const SCEV *> &Ops,
|
||||||
static_cast<SCEVAddExpr *>(UniqueSCEVs.FindNodeOrInsertPos(ID, IP));
|
static_cast<SCEVAddExpr *>(UniqueSCEVs.FindNodeOrInsertPos(ID, IP));
|
||||||
if (!S) {
|
if (!S) {
|
||||||
S = SCEVAllocator.Allocate<SCEVAddExpr>();
|
S = SCEVAllocator.Allocate<SCEVAddExpr>();
|
||||||
const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
|
new (S) SCEVAddExpr(ID, Ops);
|
||||||
std::uninitialized_copy(Ops.begin(), Ops.end(), O);
|
|
||||||
new (S) SCEVAddExpr(ID, O, Ops.size());
|
|
||||||
UniqueSCEVs.InsertNode(S, IP);
|
UniqueSCEVs.InsertNode(S, IP);
|
||||||
}
|
}
|
||||||
if (HasNUW) S->setHasNoUnsignedWrap(true);
|
if (HasNUW) S->setHasNoUnsignedWrap(true);
|
||||||
|
@ -1823,9 +1820,7 @@ const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl<const SCEV *> &Ops,
|
||||||
static_cast<SCEVMulExpr *>(UniqueSCEVs.FindNodeOrInsertPos(ID, IP));
|
static_cast<SCEVMulExpr *>(UniqueSCEVs.FindNodeOrInsertPos(ID, IP));
|
||||||
if (!S) {
|
if (!S) {
|
||||||
S = SCEVAllocator.Allocate<SCEVMulExpr>();
|
S = SCEVAllocator.Allocate<SCEVMulExpr>();
|
||||||
const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
|
new (S) SCEVMulExpr(ID, Ops);
|
||||||
std::uninitialized_copy(Ops.begin(), Ops.end(), O);
|
|
||||||
new (S) SCEVMulExpr(ID, O, Ops.size());
|
|
||||||
UniqueSCEVs.InsertNode(S, IP);
|
UniqueSCEVs.InsertNode(S, IP);
|
||||||
}
|
}
|
||||||
if (HasNUW) S->setHasNoUnsignedWrap(true);
|
if (HasNUW) S->setHasNoUnsignedWrap(true);
|
||||||
|
@ -1885,7 +1880,9 @@ const SCEV *ScalarEvolution::getUDivExpr(const SCEV *LHS,
|
||||||
const SCEV *Op = M->getOperand(i);
|
const SCEV *Op = M->getOperand(i);
|
||||||
const SCEV *Div = getUDivExpr(Op, RHSC);
|
const SCEV *Div = getUDivExpr(Op, RHSC);
|
||||||
if (!isa<SCEVUDivExpr>(Div) && getMulExpr(Div, RHSC) == Op) {
|
if (!isa<SCEVUDivExpr>(Div) && getMulExpr(Div, RHSC) == Op) {
|
||||||
Operands = SmallVector<const SCEV *, 4>(M->op_begin(), M->op_end());
|
const SmallVectorImpl<const SCEV *> &MOperands = M->getOperands();
|
||||||
|
Operands = SmallVector<const SCEV *, 4>(MOperands.begin(),
|
||||||
|
MOperands.end());
|
||||||
Operands[i] = Div;
|
Operands[i] = Div;
|
||||||
return getMulExpr(Operands);
|
return getMulExpr(Operands);
|
||||||
}
|
}
|
||||||
|
@ -2034,9 +2031,7 @@ ScalarEvolution::getAddRecExpr(SmallVectorImpl<const SCEV *> &Operands,
|
||||||
static_cast<SCEVAddRecExpr *>(UniqueSCEVs.FindNodeOrInsertPos(ID, IP));
|
static_cast<SCEVAddRecExpr *>(UniqueSCEVs.FindNodeOrInsertPos(ID, IP));
|
||||||
if (!S) {
|
if (!S) {
|
||||||
S = SCEVAllocator.Allocate<SCEVAddRecExpr>();
|
S = SCEVAllocator.Allocate<SCEVAddRecExpr>();
|
||||||
const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Operands.size());
|
new (S) SCEVAddRecExpr(ID, Operands, L);
|
||||||
std::uninitialized_copy(Operands.begin(), Operands.end(), O);
|
|
||||||
new (S) SCEVAddRecExpr(ID, O, Operands.size(), L);
|
|
||||||
UniqueSCEVs.InsertNode(S, IP);
|
UniqueSCEVs.InsertNode(S, IP);
|
||||||
}
|
}
|
||||||
if (HasNUW) S->setHasNoUnsignedWrap(true);
|
if (HasNUW) S->setHasNoUnsignedWrap(true);
|
||||||
|
@ -2136,9 +2131,7 @@ ScalarEvolution::getSMaxExpr(SmallVectorImpl<const SCEV *> &Ops) {
|
||||||
void *IP = 0;
|
void *IP = 0;
|
||||||
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
||||||
SCEV *S = SCEVAllocator.Allocate<SCEVSMaxExpr>();
|
SCEV *S = SCEVAllocator.Allocate<SCEVSMaxExpr>();
|
||||||
const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
|
new (S) SCEVSMaxExpr(ID, Ops);
|
||||||
std::uninitialized_copy(Ops.begin(), Ops.end(), O);
|
|
||||||
new (S) SCEVSMaxExpr(ID, O, Ops.size());
|
|
||||||
UniqueSCEVs.InsertNode(S, IP);
|
UniqueSCEVs.InsertNode(S, IP);
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
|
@ -2235,9 +2228,7 @@ ScalarEvolution::getUMaxExpr(SmallVectorImpl<const SCEV *> &Ops) {
|
||||||
void *IP = 0;
|
void *IP = 0;
|
||||||
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
|
||||||
SCEV *S = SCEVAllocator.Allocate<SCEVUMaxExpr>();
|
SCEV *S = SCEVAllocator.Allocate<SCEVUMaxExpr>();
|
||||||
const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
|
new (S) SCEVUMaxExpr(ID, Ops);
|
||||||
std::uninitialized_copy(Ops.begin(), Ops.end(), O);
|
|
||||||
new (S) SCEVUMaxExpr(ID, O, Ops.size());
|
|
||||||
UniqueSCEVs.InsertNode(S, IP);
|
UniqueSCEVs.InsertNode(S, IP);
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,7 +232,9 @@ static bool FactorOutConstant(const SCEV *&S,
|
||||||
const SCEVConstant *FC = cast<SCEVConstant>(Factor);
|
const SCEVConstant *FC = cast<SCEVConstant>(Factor);
|
||||||
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(FC->getValue()->getValue())) {
|
if (!C->getValue()->getValue().srem(FC->getValue()->getValue())) {
|
||||||
SmallVector<const SCEV *, 4> NewMulOps(M->op_begin(), M->op_end());
|
const SmallVectorImpl<const SCEV *> &MOperands = M->getOperands();
|
||||||
|
SmallVector<const SCEV *, 4> NewMulOps(MOperands.begin(),
|
||||||
|
MOperands.end());
|
||||||
NewMulOps[0] =
|
NewMulOps[0] =
|
||||||
SE.getConstant(C->getValue()->getValue().sdiv(
|
SE.getConstant(C->getValue()->getValue().sdiv(
|
||||||
FC->getValue()->getValue()));
|
FC->getValue()->getValue()));
|
||||||
|
@ -247,7 +249,9 @@ static bool FactorOutConstant(const SCEV *&S,
|
||||||
const SCEV *Remainder = SE.getIntegerSCEV(0, SOp->getType());
|
const SCEV *Remainder = SE.getIntegerSCEV(0, SOp->getType());
|
||||||
if (FactorOutConstant(SOp, Remainder, Factor, SE, TD) &&
|
if (FactorOutConstant(SOp, Remainder, Factor, SE, TD) &&
|
||||||
Remainder->isZero()) {
|
Remainder->isZero()) {
|
||||||
SmallVector<const SCEV *, 4> NewMulOps(M->op_begin(), M->op_end());
|
const SmallVectorImpl<const SCEV *> &MOperands = M->getOperands();
|
||||||
|
SmallVector<const SCEV *, 4> NewMulOps(MOperands.begin(),
|
||||||
|
MOperands.end());
|
||||||
NewMulOps[i] = SOp;
|
NewMulOps[i] = SOp;
|
||||||
S = SE.getMulExpr(NewMulOps);
|
S = SE.getMulExpr(NewMulOps);
|
||||||
return true;
|
return true;
|
||||||
|
@ -293,11 +297,13 @@ static void SimplifyAddOperands(SmallVectorImpl<const SCEV *> &Ops,
|
||||||
SE.getAddExpr(NoAddRecs);
|
SE.getAddExpr(NoAddRecs);
|
||||||
// If it returned an add, use the operands. Otherwise it simplified
|
// If it returned an add, use the operands. Otherwise it simplified
|
||||||
// the sum into a single value, so just use that.
|
// the sum into a single value, so just use that.
|
||||||
Ops.clear();
|
|
||||||
if (const SCEVAddExpr *Add = dyn_cast<SCEVAddExpr>(Sum))
|
if (const SCEVAddExpr *Add = dyn_cast<SCEVAddExpr>(Sum))
|
||||||
Ops.insert(Ops.end(), Add->op_begin(), Add->op_begin());
|
Ops = Add->getOperands();
|
||||||
else if (!Sum->isZero())
|
else {
|
||||||
Ops.push_back(Sum);
|
Ops.clear();
|
||||||
|
if (!Sum->isZero())
|
||||||
|
Ops.push_back(Sum);
|
||||||
|
}
|
||||||
// Then append the addrecs.
|
// Then append the addrecs.
|
||||||
Ops.insert(Ops.end(), AddRecs.begin(), AddRecs.end());
|
Ops.insert(Ops.end(), AddRecs.begin(), AddRecs.end());
|
||||||
}
|
}
|
||||||
|
@ -1054,9 +1060,10 @@ Value *SCEVExpander::visitAddRecExpr(const SCEVAddRecExpr *S) {
|
||||||
if (CanonicalIV &&
|
if (CanonicalIV &&
|
||||||
SE.getTypeSizeInBits(CanonicalIV->getType()) >
|
SE.getTypeSizeInBits(CanonicalIV->getType()) >
|
||||||
SE.getTypeSizeInBits(Ty)) {
|
SE.getTypeSizeInBits(Ty)) {
|
||||||
SmallVector<const SCEV *, 4> NewOps(S->getNumOperands());
|
const SmallVectorImpl<const SCEV *> &Ops = S->getOperands();
|
||||||
for (unsigned i = 0, e = S->getNumOperands(); i != e; ++i)
|
SmallVector<const SCEV *, 4> NewOps(Ops.size());
|
||||||
NewOps[i] = SE.getAnyExtendExpr(S->op_begin()[i], CanonicalIV->getType());
|
for (unsigned i = 0, e = Ops.size(); i != e; ++i)
|
||||||
|
NewOps[i] = SE.getAnyExtendExpr(Ops[i], CanonicalIV->getType());
|
||||||
Value *V = expand(SE.getAddRecExpr(NewOps, S->getLoop()));
|
Value *V = expand(SE.getAddRecExpr(NewOps, S->getLoop()));
|
||||||
BasicBlock *SaveInsertBB = Builder.GetInsertBlock();
|
BasicBlock *SaveInsertBB = Builder.GetInsertBlock();
|
||||||
BasicBlock::iterator SaveInsertPt = Builder.GetInsertPoint();
|
BasicBlock::iterator SaveInsertPt = Builder.GetInsertPoint();
|
||||||
|
@ -1071,7 +1078,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()) {
|
||||||
SmallVector<const SCEV *, 4> NewOps(S->op_begin(), S->op_end());
|
const SmallVectorImpl<const SCEV *> &SOperands = S->getOperands();
|
||||||
|
SmallVector<const SCEV *, 4> NewOps(SOperands.begin(), SOperands.end());
|
||||||
NewOps[0] = SE.getIntegerSCEV(0, Ty);
|
NewOps[0] = SE.getIntegerSCEV(0, Ty);
|
||||||
const SCEV *Rest = SE.getAddRecExpr(NewOps, L);
|
const SCEV *Rest = SE.getAddRecExpr(NewOps, L);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue