X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=include%2Fllvm%2FAnalysis%2FScalarEvolutionExpander.h;h=e5647860db5c136f5d043f36f7c60931937399a4;hp=8ec2078258d111be7a78ee6bbfe48f13cbd7fd24;hb=72644dfdcd64c186ae04e7a4a125429603e3e7cd;hpb=cd52a7a381a73c53ec4ef517ad87f19808cb1a28 diff --git a/include/llvm/Analysis/ScalarEvolutionExpander.h b/include/llvm/Analysis/ScalarEvolutionExpander.h index 8ec2078258d..e5647860db5 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpander.h +++ b/include/llvm/Analysis/ScalarEvolutionExpander.h @@ -117,9 +117,13 @@ namespace llvm { /// \brief Return true for expressions that may incur non-trivial cost to /// evaluate at runtime. - bool isHighCostExpansion(const SCEV *Expr, Loop *L) { + /// 'At' is an optional parameter which specifies point in code where user + /// is going to expand this expression. Sometimes this knowledge can lead to + /// a more accurate cost estimation. + bool isHighCostExpansion(const SCEV *Expr, Loop *L, + const Instruction *At = nullptr) { SmallPtrSet Processed; - return isHighCostExpansionHelper(Expr, L, Processed); + return isHighCostExpansionHelper(Expr, L, At, Processed); } /// \brief This method returns the canonical induction variable of the @@ -193,11 +197,20 @@ namespace llvm { void setChainedPhi(PHINode *PN) { ChainedPhis.insert(PN); } + /// \brief Try to find LLVM IR value for 'S' available at the point 'At'. + // 'L' is a hint which tells in which loop to look for the suitable value. + // On success return value which is equivalent to the expanded 'S' at point + // 'At'. Return nullptr if value was not found. + // Note that this function does not perform exhaustive search. I.e if it + // didn't find any value it does not mean that there is no such value. + Value *findExistingExpansion(const SCEV *S, const Instruction *At, Loop *L); + private: LLVMContext &getContext() const { return SE.getContext(); } /// \brief Recursive helper function for isHighCostExpansion. bool isHighCostExpansionHelper(const SCEV *S, Loop *L, + const Instruction *At, SmallPtrSetImpl &Processed); /// \brief Insert the specified binary operator, doing a small amount