From ebf78f18df84a63295c748148f54f091234ed099 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 17 Mar 2010 19:54:53 +0000 Subject: Revert 98755, which may be causing trouble. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98762 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ScalarEvolution.cpp | 41 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 25 deletions(-) (limited to 'lib/Analysis/ScalarEvolution.cpp') diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 12042c2ee6..15f072dbeb 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -248,10 +248,10 @@ void SCEVSignExtendExpr::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(); 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 << ")"; } @@ -329,7 +329,7 @@ SCEVAddRecExpr::properlyDominates(BasicBlock *BB, DominatorTree *DT) const { void SCEVAddRecExpr::print(raw_ostream &OS) const { 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 << "}<"; WriteAsOperand(OS, L->getHeader(), /*PrintType=*/false); @@ -1202,23 +1202,23 @@ static bool CollectAddOperandsWithScales(DenseMap &M, SmallVector &NewOps, APInt &AccumulatedConstant, - const SCEV *const *Ops, size_t NumOperands, + const SmallVectorImpl &Ops, const APInt &Scale, ScalarEvolution &SE) { bool Interesting = false; // 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(Ops[i]); if (Mul && isa(Mul->getOperand(0))) { APInt NewScale = Scale * cast(Mul->getOperand(0))->getValue()->getValue(); if (Mul->getNumOperands() == 2 && isa(Mul->getOperand(1))) { // A multiplication of a constant with another add; recurse. - const SCEVAddExpr *Add = cast(Mul->getOperand(1)); Interesting |= CollectAddOperandsWithScales(M, NewOps, AccumulatedConstant, - Add->op_begin(), Add->getNumOperands(), + cast(Mul->getOperand(1)) + ->getOperands(), NewScale, SE); } else { // A multiplication of a constant with some other value. Update @@ -1427,8 +1427,7 @@ const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl &Ops, SmallVector NewOps; APInt AccumulatedConstant(BitWidth, 0); if (CollectAddOperandsWithScales(M, NewOps, AccumulatedConstant, - Ops.data(), Ops.size(), - APInt(BitWidth, 1), *this)) { + Ops, APInt(BitWidth, 1), *this)) { // Some interesting folding opportunity is present, so its worthwhile to // re-generate the operands list. Group the operands by constant scale, // to avoid multiplying by the same constant scale multiple times. @@ -1613,9 +1612,7 @@ const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl &Ops, static_cast(UniqueSCEVs.FindNodeOrInsertPos(ID, IP)); if (!S) { S = SCEVAllocator.Allocate(); - const SCEV **O = SCEVAllocator.Allocate(Ops.size()); - std::uninitialized_copy(Ops.begin(), Ops.end(), O); - new (S) SCEVAddExpr(ID, O, Ops.size()); + new (S) SCEVAddExpr(ID, Ops); UniqueSCEVs.InsertNode(S, IP); } if (HasNUW) S->setHasNoUnsignedWrap(true); @@ -1823,9 +1820,7 @@ const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl &Ops, static_cast(UniqueSCEVs.FindNodeOrInsertPos(ID, IP)); if (!S) { S = SCEVAllocator.Allocate(); - const SCEV **O = SCEVAllocator.Allocate(Ops.size()); - std::uninitialized_copy(Ops.begin(), Ops.end(), O); - new (S) SCEVMulExpr(ID, O, Ops.size()); + new (S) SCEVMulExpr(ID, Ops); UniqueSCEVs.InsertNode(S, IP); } if (HasNUW) S->setHasNoUnsignedWrap(true); @@ -1885,7 +1880,9 @@ const SCEV *ScalarEvolution::getUDivExpr(const SCEV *LHS, const SCEV *Op = M->getOperand(i); const SCEV *Div = getUDivExpr(Op, RHSC); if (!isa(Div) && getMulExpr(Div, RHSC) == Op) { - Operands = SmallVector(M->op_begin(), M->op_end()); + const SmallVectorImpl &MOperands = M->getOperands(); + Operands = SmallVector(MOperands.begin(), + MOperands.end()); Operands[i] = Div; return getMulExpr(Operands); } @@ -2034,9 +2031,7 @@ ScalarEvolution::getAddRecExpr(SmallVectorImpl &Operands, static_cast(UniqueSCEVs.FindNodeOrInsertPos(ID, IP)); if (!S) { S = SCEVAllocator.Allocate(); - const SCEV **O = SCEVAllocator.Allocate(Operands.size()); - std::uninitialized_copy(Operands.begin(), Operands.end(), O); - new (S) SCEVAddRecExpr(ID, O, Operands.size(), L); + new (S) SCEVAddRecExpr(ID, Operands, L); UniqueSCEVs.InsertNode(S, IP); } if (HasNUW) S->setHasNoUnsignedWrap(true); @@ -2136,9 +2131,7 @@ ScalarEvolution::getSMaxExpr(SmallVectorImpl &Ops) { void *IP = 0; if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S; SCEV *S = SCEVAllocator.Allocate(); - const SCEV **O = SCEVAllocator.Allocate(Ops.size()); - std::uninitialized_copy(Ops.begin(), Ops.end(), O); - new (S) SCEVSMaxExpr(ID, O, Ops.size()); + new (S) SCEVSMaxExpr(ID, Ops); UniqueSCEVs.InsertNode(S, IP); return S; } @@ -2235,9 +2228,7 @@ ScalarEvolution::getUMaxExpr(SmallVectorImpl &Ops) { void *IP = 0; if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S; SCEV *S = SCEVAllocator.Allocate(); - const SCEV **O = SCEVAllocator.Allocate(Ops.size()); - std::uninitialized_copy(Ops.begin(), Ops.end(), O); - new (S) SCEVUMaxExpr(ID, O, Ops.size()); + new (S) SCEVUMaxExpr(ID, Ops); UniqueSCEVs.InsertNode(S, IP); return S; } -- cgit v1.2.3