[SCEV] Refactor out isHighCostExpansion. NFCI.

Summary:
Move isHighCostExpansion from IndVarSimplify to SCEVExpander.  This
exposed function will be used in a subsequent change.

Reviewers: bogner, atrick

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D8995

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234844 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sanjoy Das
2015-04-14 03:20:28 +00:00
parent 41ed49389b
commit dee1e82714
3 changed files with 74 additions and 56 deletions

View File

@@ -116,6 +116,13 @@ namespace llvm {
ChainedPhis.clear();
}
/// isHighCostExpansion - Return true for expressions that may incur
/// non-trivial cost to evaluate at runtime.
bool isHighCostExpansion(const SCEV *Expr, Loop *L) {
SmallPtrSet<const SCEV *, 8> Processed;
return isHighCostExpansionHelper(Expr, L, Processed);
}
/// getOrInsertCanonicalInductionVariable - This method returns the
/// canonical induction variable of the specified type for the specified
/// loop (inserting one if there is none). A canonical induction variable
@@ -192,6 +199,11 @@ namespace llvm {
private:
LLVMContext &getContext() const { return SE.getContext(); }
/// isHighCostExpansionHelper - Recursive helper function for
/// isHighCostExpansion.
bool isHighCostExpansionHelper(const SCEV *S, Loop *L,
SmallPtrSetImpl<const SCEV *> &Processed);
/// InsertBinop - Insert the specified binary operator, doing a small amount
/// of work to avoid inserting an obviously redundant operation.
Value *InsertBinop(Instruction::BinaryOps Opcode, Value *LHS, Value *RHS);