diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2016-01-13 19:58:01 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2016-01-13 19:58:01 +0000 | 
| commit | 050e163ae8b4bb6eb252b59e2f8f36e68ae9239d (patch) | |
| tree | 7376a0c71aad05d327e5b1dcbceb3311a10f9f29 /lib/Transforms/Vectorize/SLPVectorizer.cpp | |
| parent | 8a6c1c25bce0267ee4072bd7b786b921e8a66a35 (diff) | |
Notes
Diffstat (limited to 'lib/Transforms/Vectorize/SLPVectorizer.cpp')
| -rw-r--r-- | lib/Transforms/Vectorize/SLPVectorizer.cpp | 44 | 
1 files changed, 21 insertions, 23 deletions
diff --git a/lib/Transforms/Vectorize/SLPVectorizer.cpp b/lib/Transforms/Vectorize/SLPVectorizer.cpp index 40abfc759e0ab..f69a4e52c7e1e 100644 --- a/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -222,7 +222,7 @@ static void propagateIRFlags(Value *I, ArrayRef<Value *> VL) {      }    }  } -   +  /// \returns \p I after propagating metadata from \p VL.  static Instruction *propagateMetadata(Instruction *I, ArrayRef<Value *> VL) {    Instruction *I0 = cast<Instruction>(VL[0]); @@ -506,7 +506,7 @@ private:      }      return Last;    } -   +    /// -- Vectorization State --    /// Holds all of the tree entries.    std::vector<TreeEntry> VectorizableTree; @@ -884,7 +884,7 @@ private:      /// The current size of the scheduling region.      int ScheduleRegionSize; -     +      /// The maximum size allowed for the scheduling region.      int ScheduleRegionSizeLimit; @@ -1089,7 +1089,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth) {      newTreeEntry(VL, false);      return;    } -   +    // Check that every instructions appears once in this bundle.    for (unsigned i = 0, e = VL.size(); i < e; ++i)      for (unsigned j = i+1; j < e; ++j) @@ -1713,7 +1713,7 @@ int BoUpSLP::getSpillCost() {    int Cost = 0;    SmallPtrSet<Instruction*, 4> LiveValues; -  Instruction *PrevInst = nullptr;  +  Instruction *PrevInst = nullptr;    for (unsigned N = 0; N < VectorizableTree.size(); ++N) {      Instruction *Inst = dyn_cast<Instruction>(VectorizableTree[N].Scalars[0]); @@ -1738,7 +1738,7 @@ int BoUpSLP::getSpillCost() {      for (auto &J : PrevInst->operands()) {        if (isa<Instruction>(&*J) && ScalarToTreeEntry.count(&*J))          LiveValues.insert(cast<Instruction>(&*J)); -    }     +    }      // Now find the sequence of instructions between PrevInst and Inst.      BasicBlock::reverse_iterator InstIt(Inst->getIterator()), @@ -1782,30 +1782,29 @@ int BoUpSLP::getTreeCost() {    unsigned BundleWidth = VectorizableTree[0].Scalars.size(); -  for (unsigned i = 0, e = VectorizableTree.size(); i != e; ++i) { -    int C = getEntryCost(&VectorizableTree[i]); +  for (TreeEntry &TE : VectorizableTree) { +    int C = getEntryCost(&TE);      DEBUG(dbgs() << "SLP: Adding cost " << C << " for bundle that starts with " -          << *VectorizableTree[i].Scalars[0] << " .\n"); +          << TE.Scalars[0] << " .\n");      Cost += C;    }    SmallSet<Value *, 16> ExtractCostCalculated;    int ExtractCost = 0; -  for (UserList::iterator I = ExternalUses.begin(), E = ExternalUses.end(); -       I != E; ++I) { +  for (ExternalUser &EU : ExternalUses) {      // We only add extract cost once for the same scalar. -    if (!ExtractCostCalculated.insert(I->Scalar).second) +    if (!ExtractCostCalculated.insert(EU.Scalar).second)        continue;      // Uses by ephemeral values are free (because the ephemeral value will be      // removed prior to code generation, and so the extraction will be      // removed as well). -    if (EphValues.count(I->User)) +    if (EphValues.count(EU.User))        continue; -    VectorType *VecTy = VectorType::get(I->Scalar->getType(), BundleWidth); +    VectorType *VecTy = VectorType::get(EU.Scalar->getType(), BundleWidth);      ExtractCost += TTI->getVectorInstrCost(Instruction::ExtractElement, VecTy, -                                           I->Lane); +                                           EU.Lane);    }    Cost += getSpillCost(); @@ -2553,7 +2552,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {  }  Value *BoUpSLP::vectorizeTree() { -   +    // All blocks must be scheduled before any instructions are inserted.    for (auto &BSIter : BlocksSchedules) {      scheduleBlock(BSIter.second.get()); @@ -3074,10 +3073,10 @@ void BoUpSLP::BlockScheduling::resetSchedule() {  }  void BoUpSLP::scheduleBlock(BlockScheduling *BS) { -   +    if (!BS->ScheduleStart)      return; -   +    DEBUG(dbgs() << "SLP: schedule block " << BS->BB->getName() << "\n");    BS->resetSchedule(); @@ -3592,7 +3591,7 @@ bool SLPVectorizer::tryToVectorize(BinaryOperator *V, BoUpSLP &R) {  /// \param NumEltsToRdx The number of elements that should be reduced in the  ///        vector.  /// \param IsPairwise Whether the reduction is a pairwise or splitting -///        reduction. A pairwise reduction will generate a mask of  +///        reduction. A pairwise reduction will generate a mask of  ///        <0,2,...> or <1,3,..> while a splitting reduction will generate  ///        <2,3, undef,undef> for a vector of 4 and NumElts = 2.  /// \param IsLeft True will generate a mask of even elements, odd otherwise. @@ -3775,7 +3774,7 @@ public:      IRBuilder<> Builder(ReductionRoot);      FastMathFlags Unsafe;      Unsafe.setUnsafeAlgebra(); -    Builder.SetFastMathFlags(Unsafe); +    Builder.setFastMathFlags(Unsafe);      unsigned i = 0;      for (; i < NumReducedVals - ReduxWidth + 1; i += ReduxWidth) { @@ -4020,9 +4019,8 @@ bool SLPVectorizer::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {      // Collect the incoming values from the PHIs.      Incoming.clear(); -    for (BasicBlock::iterator instr = BB->begin(), ie = BB->end(); instr != ie; -         ++instr) { -      PHINode *P = dyn_cast<PHINode>(instr); +    for (Instruction &I : *BB) { +      PHINode *P = dyn_cast<PHINode>(&I);        if (!P)          break;  | 
