diff options
Diffstat (limited to 'include/llvm/Analysis')
| -rw-r--r-- | include/llvm/Analysis/AliasAnalysis.h | 12 | ||||
| -rw-r--r-- | include/llvm/Analysis/ConstantFolding.h | 11 | ||||
| -rw-r--r-- | include/llvm/Analysis/DominanceFrontier.h | 4 | ||||
| -rw-r--r-- | include/llvm/Analysis/IVUsers.h | 7 | ||||
| -rw-r--r-- | include/llvm/Analysis/InstructionSimplify.h | 20 | ||||
| -rw-r--r-- | include/llvm/Analysis/JumpInstrTableInfo.h | 71 | ||||
| -rw-r--r-- | include/llvm/Analysis/LibCallSemantics.h | 12 | ||||
| -rw-r--r-- | include/llvm/Analysis/LoopAccessAnalysis.h | 201 | ||||
| -rw-r--r-- | include/llvm/Analysis/LoopInfo.h | 8 | ||||
| -rw-r--r-- | include/llvm/Analysis/RegionInfo.h | 6 | ||||
| -rw-r--r-- | include/llvm/Analysis/TargetTransformInfo.h | 8 | ||||
| -rw-r--r-- | include/llvm/Analysis/TargetTransformInfoImpl.h | 48 | ||||
| -rw-r--r-- | include/llvm/Analysis/VectorUtils.h | 28 | 
13 files changed, 234 insertions, 202 deletions
| diff --git a/include/llvm/Analysis/AliasAnalysis.h b/include/llvm/Analysis/AliasAnalysis.h index f4c1167314a1..36f8199a0322 100644 --- a/include/llvm/Analysis/AliasAnalysis.h +++ b/include/llvm/Analysis/AliasAnalysis.h @@ -211,6 +211,8 @@ public:      /// (if it has any) are non-volatile loads from objects pointed to by its      /// pointer-typed arguments, with arbitrary offsets.      /// +    /// This property corresponds to the LLVM IR 'argmemonly' attribute combined +    /// with 'readonly' attribute.      /// This property corresponds to the IntrReadArgMem LLVM intrinsic flag.      OnlyReadsArgumentPointees = ArgumentPointees | Ref, @@ -218,6 +220,7 @@ public:      /// function (if it has any) are non-volatile loads and stores from objects      /// pointed to by its pointer-typed arguments, with arbitrary offsets.      /// +    /// This property corresponds to the LLVM IR 'argmemonly' attribute.      /// This property corresponds to the IntrReadWriteArgMem LLVM intrinsic flag.      OnlyAccessesArgumentPointees = ArgumentPointees | ModRef, @@ -518,14 +521,6 @@ public:    ///    virtual void deleteValue(Value *V); -  /// copyValue - This method should be used whenever a preexisting value in the -  /// program is copied or cloned, introducing a new value.  Note that analysis -  /// implementations should tolerate clients that use this method to introduce -  /// the same value multiple times: if the analysis already knows about a -  /// value, it should ignore the request. -  /// -  virtual void copyValue(Value *From, Value *To); -    /// addEscapingUse - This method should be used whenever an escaping use is    /// added to a pointer value.  Analysis implementations may either return    /// conservative responses for that value in the future, or may recompute @@ -541,7 +536,6 @@ public:    /// above, and it provided as a helper to simplify client code.    ///    void replaceWithNewValue(Value *Old, Value *New) { -    copyValue(Old, New);      deleteValue(Old);    }  }; diff --git a/include/llvm/Analysis/ConstantFolding.h b/include/llvm/Analysis/ConstantFolding.h index 541a2109af6c..e8185b3b6307 100644 --- a/include/llvm/Analysis/ConstantFolding.h +++ b/include/llvm/Analysis/ConstantFolding.h @@ -72,6 +72,17 @@ namespace llvm {  Constant *ConstantFoldInsertValueInstruction(Constant *Agg, Constant *Val,                                               ArrayRef<unsigned> Idxs); +/// \brief Attempt to constant fold an extractvalue instruction with the +/// specified operands and indices.  The constant result is returned if +/// successful; if not, null is returned. +Constant *ConstantFoldExtractValueInstruction(Constant *Agg, +                                              ArrayRef<unsigned> Idxs); + +/// \brief Attempt to constant fold an extractelement instruction with the +/// specified operands and indices.  The constant result is returned if +/// successful; if not, null is returned. +Constant *ConstantFoldExtractElementInstruction(Constant *Val, Constant *Idx); +  /// ConstantFoldLoadFromConstPtr - Return the value that a load from C would  /// produce if it is constant and determinable.  If this is not determinable,  /// return null. diff --git a/include/llvm/Analysis/DominanceFrontier.h b/include/llvm/Analysis/DominanceFrontier.h index 996700efdb60..fb730054a8e5 100644 --- a/include/llvm/Analysis/DominanceFrontier.h +++ b/include/llvm/Analysis/DominanceFrontier.h @@ -202,8 +202,8 @@ public:    void dump() const;  }; -EXTERN_TEMPLATE_INSTANTIATION(class DominanceFrontierBase<BasicBlock>); -EXTERN_TEMPLATE_INSTANTIATION(class ForwardDominanceFrontierBase<BasicBlock>); +extern template class DominanceFrontierBase<BasicBlock>; +extern template class ForwardDominanceFrontierBase<BasicBlock>;  } // End llvm namespace diff --git a/include/llvm/Analysis/IVUsers.h b/include/llvm/Analysis/IVUsers.h index ae9c1f5bd9ac..00dbcbdd7806 100644 --- a/include/llvm/Analysis/IVUsers.h +++ b/include/llvm/Analysis/IVUsers.h @@ -21,6 +21,7 @@  namespace llvm { +class AssumptionCache;  class DominatorTree;  class Instruction;  class Value; @@ -119,15 +120,19 @@ private:  class IVUsers : public LoopPass {    friend class IVStrideUse;    Loop *L; +  AssumptionCache *AC;    LoopInfo *LI;    DominatorTree *DT;    ScalarEvolution *SE; -  SmallPtrSet<Instruction*,16> Processed; +  SmallPtrSet<Instruction*, 16> Processed;    /// IVUses - A list of all tracked IV uses of induction variable expressions    /// we are interested in.    ilist<IVStrideUse> IVUses; +  // Ephemeral values used by @llvm.assume in this function. +  SmallPtrSet<const Value *, 32> EphValues; +    void getAnalysisUsage(AnalysisUsage &AU) const override;    bool runOnLoop(Loop *L, LPPassManager &LPM) override; diff --git a/include/llvm/Analysis/InstructionSimplify.h b/include/llvm/Analysis/InstructionSimplify.h index 706bd8000d3a..d44c5ff4078d 100644 --- a/include/llvm/Analysis/InstructionSimplify.h +++ b/include/llvm/Analysis/InstructionSimplify.h @@ -212,7 +212,7 @@ namespace llvm {    /// SimplifyFCmpInst - Given operands for an FCmpInst, see if we can    /// fold the result.  If not, this returns null.    Value *SimplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS, -                          const DataLayout &DL, +                          FastMathFlags FMF, const DataLayout &DL,                            const TargetLibraryInfo *TLI = nullptr,                            const DominatorTree *DT = nullptr,                            AssumptionCache *AC = nullptr, @@ -244,6 +244,24 @@ namespace llvm {                                   AssumptionCache *AC = nullptr,                                   const Instruction *CxtI = nullptr); +  /// \brief Given operands for an ExtractValueInst, see if we can fold the +  /// result.  If not, this returns null. +  Value *SimplifyExtractValueInst(Value *Agg, ArrayRef<unsigned> Idxs, +                                  const DataLayout &DL, +                                  const TargetLibraryInfo *TLI = nullptr, +                                  const DominatorTree *DT = nullptr, +                                  AssumptionCache *AC = nullptr, +                                  const Instruction *CxtI = nullptr); + +  /// \brief Given operands for an ExtractElementInst, see if we can fold the +  /// result.  If not, this returns null. +  Value *SimplifyExtractElementInst(Value *Vec, Value *Idx, +                                    const DataLayout &DL, +                                    const TargetLibraryInfo *TLI = nullptr, +                                    const DominatorTree *DT = nullptr, +                                    AssumptionCache *AC = nullptr, +                                    const Instruction *CxtI = nullptr); +    /// SimplifyTruncInst - Given operands for an TruncInst, see if we can fold    /// the result.  If not, this returns null.    Value *SimplifyTruncInst(Value *Op, Type *Ty, const DataLayout &DL, diff --git a/include/llvm/Analysis/JumpInstrTableInfo.h b/include/llvm/Analysis/JumpInstrTableInfo.h deleted file mode 100644 index b6dad478cdf2..000000000000 --- a/include/llvm/Analysis/JumpInstrTableInfo.h +++ /dev/null @@ -1,71 +0,0 @@ -//===-- JumpInstrTableInfo.h: Info for Jump-Instruction Tables --*- C++ -*-===// -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -/// -/// \file -/// \brief Information about jump-instruction tables that have been created by -/// JumpInstrTables pass. -/// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_ANALYSIS_JUMPINSTRTABLEINFO_H -#define LLVM_ANALYSIS_JUMPINSTRTABLEINFO_H - -#include "llvm/ADT/DenseMap.h" -#include "llvm/Pass.h" -#include <vector> - -namespace llvm { -class Function; -class FunctionType; - -/// This class stores information about jump-instruction tables created by the -/// JumpInstrTables pass (in lib/CodeGen/JumpInstrTables.cpp). Each table is a -/// map from a function type to a vector of pairs. The first element of each -/// pair is the function that has the jumptable annotation. The second element -/// is a function that was declared by JumpInstrTables and used to replace all -/// address-taking sites for the original function. -/// -/// The information in this pass is used in AsmPrinter -/// (lib/CodeGen/AsmPrinter/AsmPrinter.cpp) to generate the required assembly -/// for the jump-instruction tables. -class JumpInstrTableInfo : public ImmutablePass { -public: -  static char ID; - -  /// The default byte alignment for jump tables is 16, which is large but -  /// usually safe. -  JumpInstrTableInfo(uint64_t ByteAlign = 16); -  ~JumpInstrTableInfo() override; -  const char *getPassName() const override { -    return "Jump-Instruction Table Info"; -  } - -  typedef std::pair<Function *, Function *> JumpPair; -  typedef DenseMap<FunctionType *, std::vector<JumpPair> > JumpTables; - -  /// Inserts an entry in a table, adding the table if it doesn't exist. -  void insertEntry(FunctionType *TableFunTy, Function *Target, Function *Jump); - -  /// Gets the tables. -  const JumpTables &getTables() const { return Tables; } - -  /// Gets the alignment in bytes of a jumptable entry. -  uint64_t entryByteAlignment() const { return ByteAlignment; } -private: -  JumpTables Tables; - -  /// A power-of-two alignment of a jumptable entry. -  uint64_t ByteAlignment; -}; - -/// Creates a JumpInstrTableInfo pass with the given bound on entry size. This -/// bound specifies the maximum number of bytes needed to represent an -/// unconditional jump or a trap instruction in the back end currently in use. -ModulePass *createJumpInstrTableInfoPass(unsigned Bound); -} - -#endif /* LLVM_ANALYSIS_JUMPINSTRTABLEINFO_H */ diff --git a/include/llvm/Analysis/LibCallSemantics.h b/include/llvm/Analysis/LibCallSemantics.h index 170e2a49a8ea..b4bef310e590 100644 --- a/include/llvm/Analysis/LibCallSemantics.h +++ b/include/llvm/Analysis/LibCallSemantics.h @@ -206,6 +206,18 @@ class InvokeInst;      llvm_unreachable("invalid enum");    } +  /// \brief Return true if this personality may be safely removed if there +  /// are no invoke instructions remaining in the current function. +  inline bool isNoOpWithoutInvoke(EHPersonality Pers) { +    switch (Pers) { +    case EHPersonality::Unknown: +      return false; +    // All known personalities currently have this behavior +    default: return true; +    } +    llvm_unreachable("invalid enum"); +  } +    bool canSimplifyInvokeNoUnwind(const Function *F);  } // end namespace llvm diff --git a/include/llvm/Analysis/LoopAccessAnalysis.h b/include/llvm/Analysis/LoopAccessAnalysis.h index 7b635a8b4960..476e4b6686bb 100644 --- a/include/llvm/Analysis/LoopAccessAnalysis.h +++ b/include/llvm/Analysis/LoopAccessAnalysis.h @@ -292,6 +292,133 @@ private:    bool couldPreventStoreLoadForward(unsigned Distance, unsigned TypeByteSize);  }; +/// \brief Holds information about the memory runtime legality checks to verify +/// that a group of pointers do not overlap. +class RuntimePointerChecking { +public: +  struct PointerInfo { +    /// Holds the pointer value that we need to check. +    TrackingVH<Value> PointerValue; +    /// Holds the pointer value at the beginning of the loop. +    const SCEV *Start; +    /// Holds the pointer value at the end of the loop. +    const SCEV *End; +    /// Holds the information if this pointer is used for writing to memory. +    bool IsWritePtr; +    /// Holds the id of the set of pointers that could be dependent because of a +    /// shared underlying object. +    unsigned DependencySetId; +    /// Holds the id of the disjoint alias set to which this pointer belongs. +    unsigned AliasSetId; +    /// SCEV for the access. +    const SCEV *Expr; + +    PointerInfo(Value *PointerValue, const SCEV *Start, const SCEV *End, +                bool IsWritePtr, unsigned DependencySetId, unsigned AliasSetId, +                const SCEV *Expr) +        : PointerValue(PointerValue), Start(Start), End(End), +          IsWritePtr(IsWritePtr), DependencySetId(DependencySetId), +          AliasSetId(AliasSetId), Expr(Expr) {} +  }; + +  RuntimePointerChecking(ScalarEvolution *SE) : Need(false), SE(SE) {} + +  /// Reset the state of the pointer runtime information. +  void reset() { +    Need = false; +    Pointers.clear(); +  } + +  /// Insert a pointer and calculate the start and end SCEVs. +  void insert(Loop *Lp, Value *Ptr, bool WritePtr, unsigned DepSetId, +              unsigned ASId, const ValueToValueMap &Strides); + +  /// \brief No run-time memory checking is necessary. +  bool empty() const { return Pointers.empty(); } + +  /// A grouping of pointers. A single memcheck is required between +  /// two groups. +  struct CheckingPtrGroup { +    /// \brief Create a new pointer checking group containing a single +    /// pointer, with index \p Index in RtCheck. +    CheckingPtrGroup(unsigned Index, RuntimePointerChecking &RtCheck) +        : RtCheck(RtCheck), High(RtCheck.Pointers[Index].End), +          Low(RtCheck.Pointers[Index].Start) { +      Members.push_back(Index); +    } + +    /// \brief Tries to add the pointer recorded in RtCheck at index +    /// \p Index to this pointer checking group. We can only add a pointer +    /// to a checking group if we will still be able to get +    /// the upper and lower bounds of the check. Returns true in case +    /// of success, false otherwise. +    bool addPointer(unsigned Index); + +    /// Constitutes the context of this pointer checking group. For each +    /// pointer that is a member of this group we will retain the index +    /// at which it appears in RtCheck. +    RuntimePointerChecking &RtCheck; +    /// The SCEV expression which represents the upper bound of all the +    /// pointers in this group. +    const SCEV *High; +    /// The SCEV expression which represents the lower bound of all the +    /// pointers in this group. +    const SCEV *Low; +    /// Indices of all the pointers that constitute this grouping. +    SmallVector<unsigned, 2> Members; +  }; + +  /// \brief Groups pointers such that a single memcheck is required +  /// between two different groups. This will clear the CheckingGroups vector +  /// and re-compute it. We will only group dependecies if \p UseDependencies +  /// is true, otherwise we will create a separate group for each pointer. +  void groupChecks(MemoryDepChecker::DepCandidates &DepCands, +                   bool UseDependencies); + +  /// \brief Decide if we need to add a check between two groups of pointers, +  /// according to needsChecking. +  bool needsChecking(const CheckingPtrGroup &M, const CheckingPtrGroup &N, +                     const SmallVectorImpl<int> *PtrPartition) const; + +  /// \brief Return true if any pointer requires run-time checking according +  /// to needsChecking. +  bool needsAnyChecking(const SmallVectorImpl<int> *PtrPartition) const; + +  /// \brief Returns the number of run-time checks required according to +  /// needsChecking. +  unsigned getNumberOfChecks(const SmallVectorImpl<int> *PtrPartition) const; + +  /// \brief Print the list run-time memory checks necessary. +  /// +  /// If \p PtrPartition is set, it contains the partition number for +  /// pointers (-1 if the pointer belongs to multiple partitions).  In this +  /// case omit checks between pointers belonging to the same partition. +  void print(raw_ostream &OS, unsigned Depth = 0, +             const SmallVectorImpl<int> *PtrPartition = nullptr) const; + +  /// This flag indicates if we need to add the runtime check. +  bool Need; + +  /// Information about the pointers that may require checking. +  SmallVector<PointerInfo, 2> Pointers; + +  /// Holds a partitioning of pointers into "check groups". +  SmallVector<CheckingPtrGroup, 2> CheckingGroups; + +private: +  /// \brief Decide whether we need to issue a run-time check for pointer at +  /// index \p I and \p J to prove their independence. +  /// +  /// If \p PtrPartition is set, it contains the partition number for +  /// pointers (-1 if the pointer belongs to multiple partitions).  In this +  /// case omit checks between pointers belonging to the same partition. +  bool needsChecking(unsigned I, unsigned J, +                     const SmallVectorImpl<int> *PtrPartition) const; + +  /// Holds a pointer to the ScalarEvolution analysis. +  ScalarEvolution *SE; +}; +  /// \brief Drive the analysis of memory accesses in the loop  ///  /// This class is responsible for analyzing the memory accesses of a loop.  It @@ -308,72 +435,6 @@ private:  /// RuntimePointerCheck class.  class LoopAccessInfo {  public: -  /// This struct holds information about the memory runtime legality check that -  /// a group of pointers do not overlap. -  struct RuntimePointerCheck { -    RuntimePointerCheck() : Need(false) {} - -    /// Reset the state of the pointer runtime information. -    void reset() { -      Need = false; -      Pointers.clear(); -      Starts.clear(); -      Ends.clear(); -      IsWritePtr.clear(); -      DependencySetId.clear(); -      AliasSetId.clear(); -    } - -    /// Insert a pointer and calculate the start and end SCEVs. -    void insert(ScalarEvolution *SE, Loop *Lp, Value *Ptr, bool WritePtr, -                unsigned DepSetId, unsigned ASId, -                const ValueToValueMap &Strides); - -    /// \brief No run-time memory checking is necessary. -    bool empty() const { return Pointers.empty(); } - -    /// \brief Decide whether we need to issue a run-time check for pointer at -    /// index \p I and \p J to prove their independence. -    /// -    /// If \p PtrPartition is set, it contains the partition number for -    /// pointers (-1 if the pointer belongs to multiple partitions).  In this -    /// case omit checks between pointers belonging to the same partition. -    bool needsChecking(unsigned I, unsigned J, -                       const SmallVectorImpl<int> *PtrPartition) const; - -    /// \brief Return true if any pointer requires run-time checking according -    /// to needsChecking. -    bool needsAnyChecking(const SmallVectorImpl<int> *PtrPartition) const; - -    /// \brief Returns the number of run-time checks required according to -    /// needsChecking. -    unsigned getNumberOfChecks(const SmallVectorImpl<int> *PtrPartition) const; - -    /// \brief Print the list run-time memory checks necessary. -    /// -    /// If \p PtrPartition is set, it contains the partition number for -    /// pointers (-1 if the pointer belongs to multiple partitions).  In this -    /// case omit checks between pointers belonging to the same partition. -    void print(raw_ostream &OS, unsigned Depth = 0, -               const SmallVectorImpl<int> *PtrPartition = nullptr) const; - -    /// This flag indicates if we need to add the runtime check. -    bool Need; -    /// Holds the pointers that we need to check. -    SmallVector<TrackingVH<Value>, 2> Pointers; -    /// Holds the pointer value at the beginning of the loop. -    SmallVector<const SCEV*, 2> Starts; -    /// Holds the pointer value at the end of the loop. -    SmallVector<const SCEV*, 2> Ends; -    /// Holds the information if this pointer is used for writing to memory. -    SmallVector<bool, 2> IsWritePtr; -    /// Holds the id of the set of pointers that could be dependent because of a -    /// shared underlying object. -    SmallVector<unsigned, 2> DependencySetId; -    /// Holds the id of the disjoint alias set to which this pointer belongs. -    SmallVector<unsigned, 2> AliasSetId; -  }; -    LoopAccessInfo(Loop *L, ScalarEvolution *SE, const DataLayout &DL,                   const TargetLibraryInfo *TLI, AliasAnalysis *AA,                   DominatorTree *DT, LoopInfo *LI, @@ -383,15 +444,15 @@ public:    /// no memory dependence cycles.    bool canVectorizeMemory() const { return CanVecMem; } -  const RuntimePointerCheck *getRuntimePointerCheck() const { -    return &PtrRtCheck; +  const RuntimePointerChecking *getRuntimePointerChecking() const { +    return &PtrRtChecking;    }    /// \brief Number of memchecks required to prove independence of otherwise    /// may-alias pointers.    unsigned getNumRuntimePointerChecks(      const SmallVectorImpl<int> *PtrPartition = nullptr) const { -    return PtrRtCheck.getNumberOfChecks(PtrPartition); +    return PtrRtChecking.getNumberOfChecks(PtrPartition);    }    /// Return true if the block BB needs to be predicated in order for the loop @@ -461,7 +522,7 @@ private:    /// We need to check that all of the pointers in this list are disjoint    /// at runtime. -  RuntimePointerCheck PtrRtCheck; +  RuntimePointerChecking PtrRtChecking;    /// \brief the Memory Dependence Checker which can determine the    /// loop-independent and loop-carried dependences between memory accesses. diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index bbcde8d9721a..3ec83f2c21fd 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -347,9 +347,7 @@ raw_ostream& operator<<(raw_ostream &OS, const LoopBase<BlockT, LoopT> &Loop) {  }  // Implementation in LoopInfoImpl.h -#ifdef __GNUC__ -__extension__ extern template class LoopBase<BasicBlock, Loop>; -#endif +extern template class LoopBase<BasicBlock, Loop>;  class Loop : public LoopBase<BasicBlock, Loop> {  public: @@ -633,9 +631,7 @@ public:  };  // Implementation in LoopInfoImpl.h -#ifdef __GNUC__ -__extension__ extern template class LoopInfoBase<BasicBlock, Loop>; -#endif +extern template class LoopInfoBase<BasicBlock, Loop>;  class LoopInfo : public LoopInfoBase<BasicBlock, Loop> {    typedef LoopInfoBase<BasicBlock, Loop> BaseT; diff --git a/include/llvm/Analysis/RegionInfo.h b/include/llvm/Analysis/RegionInfo.h index 7ceb086ee0a1..8560f1f67160 100644 --- a/include/llvm/Analysis/RegionInfo.h +++ b/include/llvm/Analysis/RegionInfo.h @@ -902,9 +902,9 @@ inline raw_ostream &operator<<(raw_ostream &OS,      return OS << Node.template getNodeAs<BlockT>()->getName();  } -EXTERN_TEMPLATE_INSTANTIATION(class RegionBase<RegionTraits<Function>>); -EXTERN_TEMPLATE_INSTANTIATION(class RegionNodeBase<RegionTraits<Function>>); -EXTERN_TEMPLATE_INSTANTIATION(class RegionInfoBase<RegionTraits<Function>>); +extern template class RegionBase<RegionTraits<Function>>; +extern template class RegionNodeBase<RegionTraits<Function>>; +extern template class RegionInfoBase<RegionTraits<Function>>;  } // End llvm namespace  #endif diff --git a/include/llvm/Analysis/TargetTransformInfo.h b/include/llvm/Analysis/TargetTransformInfo.h index bb6e266b1f5b..01f00896410e 100644 --- a/include/llvm/Analysis/TargetTransformInfo.h +++ b/include/llvm/Analysis/TargetTransformInfo.h @@ -69,7 +69,7 @@ public:    ///    /// The TTI implementation will reflect the information in the DataLayout    /// provided if non-null. -  explicit TargetTransformInfo(const DataLayout *DL); +  explicit TargetTransformInfo(const DataLayout &DL);    // Provide move semantics.    TargetTransformInfo(TargetTransformInfo &&Arg); @@ -541,7 +541,7 @@ private:  class TargetTransformInfo::Concept {  public:    virtual ~Concept() = 0; - +  virtual const DataLayout &getDataLayout() const = 0;    virtual unsigned getOperationCost(unsigned Opcode, Type *Ty, Type *OpTy) = 0;    virtual unsigned getGEPCost(const Value *Ptr,                                ArrayRef<const Value *> Operands) = 0; @@ -636,6 +636,10 @@ public:    Model(T Impl) : Impl(std::move(Impl)) {}    ~Model() override {} +  const DataLayout &getDataLayout() const override { +    return Impl.getDataLayout(); +  } +    unsigned getOperationCost(unsigned Opcode, Type *Ty, Type *OpTy) override {      return Impl.getOperationCost(Opcode, Ty, OpTy);    } diff --git a/include/llvm/Analysis/TargetTransformInfoImpl.h b/include/llvm/Analysis/TargetTransformInfoImpl.h index 403175acae02..035cb04870a1 100644 --- a/include/llvm/Analysis/TargetTransformInfoImpl.h +++ b/include/llvm/Analysis/TargetTransformInfoImpl.h @@ -30,26 +30,17 @@ class TargetTransformInfoImplBase {  protected:    typedef TargetTransformInfo TTI; -  const DataLayout *DL; +  const DataLayout &DL; -  explicit TargetTransformInfoImplBase(const DataLayout *DL) -      : DL(DL) {} +  explicit TargetTransformInfoImplBase(const DataLayout &DL) : DL(DL) {}  public:    // Provide value semantics. MSVC requires that we spell all of these out.    TargetTransformInfoImplBase(const TargetTransformInfoImplBase &Arg)        : DL(Arg.DL) {} -  TargetTransformInfoImplBase(TargetTransformInfoImplBase &&Arg) -      : DL(std::move(Arg.DL)) {} -  TargetTransformInfoImplBase & -  operator=(const TargetTransformInfoImplBase &RHS) { -    DL = RHS.DL; -    return *this; -  } -  TargetTransformInfoImplBase &operator=(TargetTransformInfoImplBase &&RHS) { -    DL = std::move(RHS.DL); -    return *this; -  } +  TargetTransformInfoImplBase(TargetTransformInfoImplBase &&Arg) : DL(Arg.DL) {} + +  const DataLayout &getDataLayout() const { return DL; }    unsigned getOperationCost(unsigned Opcode, Type *Ty, Type *OpTy) {      switch (Opcode) { @@ -70,28 +61,22 @@ public:        return TTI::TCC_Basic;      case Instruction::IntToPtr: { -      if (!DL) -        return TTI::TCC_Basic; -        // An inttoptr cast is free so long as the input is a legal integer type        // which doesn't contain values outside the range of a pointer.        unsigned OpSize = OpTy->getScalarSizeInBits(); -      if (DL->isLegalInteger(OpSize) && -          OpSize <= DL->getPointerTypeSizeInBits(Ty)) +      if (DL.isLegalInteger(OpSize) && +          OpSize <= DL.getPointerTypeSizeInBits(Ty))          return TTI::TCC_Free;        // Otherwise it's not a no-op.        return TTI::TCC_Basic;      }      case Instruction::PtrToInt: { -      if (!DL) -        return TTI::TCC_Basic; -        // A ptrtoint cast is free so long as the result is large enough to store        // the pointer, and a legal integer type.        unsigned DestSize = Ty->getScalarSizeInBits(); -      if (DL->isLegalInteger(DestSize) && -          DestSize >= DL->getPointerTypeSizeInBits(OpTy)) +      if (DL.isLegalInteger(DestSize) && +          DestSize >= DL.getPointerTypeSizeInBits(OpTy))          return TTI::TCC_Free;        // Otherwise it's not a no-op. @@ -100,7 +85,7 @@ public:      case Instruction::Trunc:        // trunc to a native type is free (assuming the target has compare and        // shift-right of the same width). -      if (DL && DL->isLegalInteger(DL->getTypeSizeInBits(Ty))) +      if (DL.isLegalInteger(DL.getTypeSizeInBits(Ty)))          return TTI::TCC_Free;        return TTI::TCC_Basic; @@ -353,8 +338,7 @@ private:    typedef TargetTransformInfoImplBase BaseT;  protected: -  explicit TargetTransformInfoImplCRTPBase(const DataLayout *DL) -      : BaseT(DL) {} +  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}  public:    // Provide value semantics. MSVC requires that we spell all of these out. @@ -362,16 +346,6 @@ public:        : BaseT(static_cast<const BaseT &>(Arg)) {}    TargetTransformInfoImplCRTPBase(TargetTransformInfoImplCRTPBase &&Arg)        : BaseT(std::move(static_cast<BaseT &>(Arg))) {} -  TargetTransformInfoImplCRTPBase & -  operator=(const TargetTransformInfoImplCRTPBase &RHS) { -    BaseT::operator=(static_cast<const BaseT &>(RHS)); -    return *this; -  } -  TargetTransformInfoImplCRTPBase & -  operator=(TargetTransformInfoImplCRTPBase &&RHS) { -    BaseT::operator=(std::move(static_cast<BaseT &>(RHS))); -    return *this; -  }    using BaseT::getCallCost; diff --git a/include/llvm/Analysis/VectorUtils.h b/include/llvm/Analysis/VectorUtils.h index aa538ecc0137..d8e9ca42e623 100644 --- a/include/llvm/Analysis/VectorUtils.h +++ b/include/llvm/Analysis/VectorUtils.h @@ -20,6 +20,12 @@  namespace llvm { +class GetElementPtrInst; +class Loop; +class ScalarEvolution; +class Type; +class Value; +  /// \brief Identify if the intrinsic is trivially vectorizable.  /// This method returns true if the intrinsic's argument types are all  /// scalars for the scalar form of the intrinsic and all vectors for @@ -51,6 +57,28 @@ Intrinsic::ID checkBinaryFloatSignature(const CallInst &I,  /// its intrinsic ID, in case it does not found it return not_intrinsic.  Intrinsic::ID getIntrinsicIDForCall(CallInst *CI, const TargetLibraryInfo *TLI); +/// \brief Find the operand of the GEP that should be checked for consecutive +/// stores. This ignores trailing indices that have no effect on the final +/// pointer. +unsigned getGEPInductionOperand(const GetElementPtrInst *Gep); + +/// \brief If the argument is a GEP, then returns the operand identified by  +/// getGEPInductionOperand. However, if there is some other non-loop-invariant  +/// operand, it returns that instead. +Value *stripGetElementPtr(Value *Ptr, ScalarEvolution *SE, Loop *Lp); + +/// \brief If a value has only one user that is a CastInst, return it. +Value *getUniqueCastUse(Value *Ptr, Loop *Lp, Type *Ty); + +/// \brief Get the stride of a pointer access in a loop. Looks for symbolic +/// strides "a[i*stride]". Returns the symbolic stride, or null otherwise. +Value *getStrideFromPointer(Value *Ptr, ScalarEvolution *SE, Loop *Lp); + +/// \brief Given a vector and an element number, see if the scalar value is +/// already around as a register, for example if it were inserted then extracted +/// from the vector. +Value *findScalarElement(Value *V, unsigned EltNo); +  } // llvm namespace  #endif | 
