class SCEVExpander

Declaration

class SCEVExpander : public SCEVVisitor { /* full declaration omitted */ };

Description

This class uses information about analyze scalars to rewrite expressions in canonical form. Clients should create an instance of this class when rewriting is needed, and destroy it when finished to allow the release of the associated memory.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:50

Inherits from: SCEVVisitor

Member Variables

private llvm::ScalarEvolution& SE
private const llvm::DataLayout& DL
private const char* IVName
private bool PreserveLCSSA
Indicates whether LCSSA phis should be created for inserted values.
private DenseMap<std::pair<const SCEV*, Instruction*>, TrackingVH<llvm::Value>> InsertedExpressions
private DenseSet<AssertingVH<llvm::Value>> InsertedValues
private DenseSet<AssertingVH<llvm::Value>> InsertedPostIncValues
private SmallPtrSet<llvm::Value*, 16> ReusedValues
Keep track of the existing IR values re-used during expansion. FIXME: Ideally re-used instructions would not be added to InsertedValues/InsertedPostIncValues.
private SmallVector<llvm::WeakVH, 2> InsertedIVs
private DenseMap<const llvm::SCEV*, const llvm::Loop*> RelevantLoops
A memoization of the "relevant" loop for a given SCEV.
private llvm::PostIncLoopSet PostIncLoops
Addrecs referring to any of the given loops are expanded in post-inc mode. For example, expanding {1,+,1} <L > in post-inc mode returns the add instruction that adds one to the phi for {0,+,1} <L >, as opposed to a new phi starting at 1. This is only supported in non-canonical mode.
private const llvm::Loop* IVIncInsertLoop
When this is non-null, addrecs expanded in the loop it indicates should be inserted with increments at IVIncInsertPos.
private llvm::Instruction* IVIncInsertPos
When expanding addrecs in the IVIncInsertLoop loop, insert the IV increment at this position.
private DenseSet<AssertingVH<llvm::PHINode>> ChainedPhis
Phis that complete an IV chain. Reuse
private bool CanonicalMode
In "canonical" form addrecs are expanded as arithmetic based on a canonical induction variable. Note that CanonicalMode doesn't guarantee that all expressions are expanded in "canonical" form. For some expressions literal mode can be preferred.
private bool LSRMode
When invoked from LSR, the expander is in "strength reduction" mode. The only difference is that phi's are only reused if they are already in "expanded" form.
private llvm::SCEVExpander::BuilderType Builder
private SmallVector< llvm::SCEVExpander::SCEVInsertPointGuard*, 8> InsertPointGuards
Stack of pointers to saved insert points, used to keep insert points consistent when instructions are moved.
private const char* DebugType

Method Overview

  • private llvm::Value * FindValueInExprValueMap(const llvm::SCEV * S, const llvm::Instruction * InsertPt)
  • private BasicBlock::iterator GetOptimalInsertionPointForCastOf(llvm::Value * V) const
  • private llvm::Value * InsertBinop(Instruction::BinaryOps Opcode, llvm::Value * LHS, llvm::Value * RHS, SCEV::NoWrapFlags Flags, bool IsSafeToHoist)
  • private llvm::Value * InsertNoopCastOfTo(llvm::Value * V, llvm::Type * Ty)
  • private llvm::Value * ReuseOrCreateCast(llvm::Value * V, llvm::Type * Ty, Instruction::CastOps Op, BasicBlock::iterator IP)
  • public SCEVExpander(llvm::ScalarEvolution & se, const llvm::DataLayout & DL, const char * name, bool PreserveLCSSA = true)
  • public void SetCurrentDebugLocation(llvm::DebugLoc L)
  • public void clear()
  • public void clearInsertPoint()
  • public void clearPostInc()
  • public void disableCanonicalMode()
  • public void enableLSRMode()
  • private llvm::Value * expand(const llvm::SCEV * S)
  • private llvm::Value * expandAddRecExprLiterally(const llvm::SCEVAddRecExpr *)
  • private llvm::Value * expandAddToGEP(const llvm::SCEV * Op, llvm::PointerType * PTy, llvm::Type * Ty, llvm::Value * V)
  • private llvm::Value * expandAddToGEP(const llvm::SCEV *const * op_begin, const llvm::SCEV *const * op_end, llvm::PointerType * PTy, llvm::Type * Ty, llvm::Value * V)
  • public llvm::Value * expandCodeFor(const llvm::SCEV * SH, llvm::Type * Ty = nullptr)
  • public llvm::Value * expandCodeFor(const llvm::SCEV * SH, llvm::Type * Ty, llvm::Instruction * I)
  • private llvm::Value * expandCodeForImpl(const llvm::SCEV * SH, llvm::Type * Ty, llvm::Instruction * I, bool Root)
  • private llvm::Value * expandCodeForImpl(const llvm::SCEV * SH, llvm::Type * Ty, bool Root)
  • public llvm::Value * expandCodeForPredicate(const llvm::SCEVPredicate * Pred, llvm::Instruction * Loc)
  • public llvm::Value * expandComparePredicate(const llvm::SCEVComparePredicate * Pred, llvm::Instruction * Loc)
  • private llvm::Value * expandIVInc(llvm::PHINode * PN, llvm::Value * StepV, const llvm::Loop * L, llvm::Type * ExpandTy, llvm::Type * IntTy, bool useSubtract)
  • private llvm::Value * expandMinMaxExpr(const llvm::SCEVNAryExpr * S, Intrinsic::ID IntrinID, llvm::Twine Name, bool IsSequential = false)
  • public llvm::Value * expandUnionPredicate(const llvm::SCEVUnionPredicate * Pred, llvm::Instruction * Loc)
  • public llvm::Value * expandWrapPredicate(const llvm::SCEVWrapPredicate * P, llvm::Instruction * Loc)
  • public BasicBlock::iterator findInsertPointAfter(llvm::Instruction * I, llvm::Instruction * MustDominate) const
  • private void fixupInsertPoints(llvm::Instruction * I)
  • private llvm::Value * fixupLCSSAFormFor(llvm::Instruction * User, unsigned int OpIdx)
  • public llvm::Value * generateOverflowCheck(const llvm::SCEVAddRecExpr * AR, llvm::Instruction * Loc, bool Signed)
  • private llvm::PHINode * getAddRecExprPHILiterally(const llvm::SCEVAddRecExpr * Normalized, const llvm::Loop * L, llvm::Type * ExpandTy, llvm::Type * IntTy, llvm::Type *& TruncTy, bool & InvertStep)
  • public SmallVector<llvm::Instruction *, 32> getAllInsertedInstructions() const
  • private llvm::LLVMContext & getContext() const
  • public llvm::DebugLoc getCurrentDebugLocation() const
  • public llvm::Instruction * getIVIncOperand(llvm::Instruction * IncV, llvm::Instruction * InsertPos, bool allowScale)
  • public const SmallVectorImpl<llvm::WeakVH> & getInsertedIVs() const
  • public llvm::Value * getRelatedExistingExpansion(const llvm::SCEV * S, const llvm::Instruction * At, llvm::Loop * L)
  • private const llvm::Loop * getRelevantLoop(const llvm::SCEV *)
  • public llvm::ScalarEvolution * getSE()
  • public bool hoistIVInc(llvm::Instruction * IncV, llvm::Instruction * InsertPos)
  • private bool isExpandedAddRecExprPHI(llvm::PHINode * PN, llvm::Instruction * IncV, const llvm::Loop * L)
  • public bool isHighCostExpansion(const llvm::SCEV * Expr, llvm::Loop * L, unsigned int Budget, const llvm::TargetTransformInfo * TTI, const llvm::Instruction * At)
  • private bool isHighCostExpansionHelper(const llvm::SCEVOperand & WorkItem, llvm::Loop * L, const llvm::Instruction & At, llvm::InstructionCost & Cost, unsigned int Budget, const llvm::TargetTransformInfo & TTI, SmallPtrSetImpl<const llvm::SCEV *> & Processed, SmallVectorImpl<llvm::SCEVOperand> & Worklist)
  • public bool isInsertedInstruction(llvm::Instruction * I) const
  • private bool isNormalAddRecExprPHI(llvm::PHINode * PN, llvm::Instruction * IncV, const llvm::Loop * L)
  • public bool isSafeToExpand(const llvm::SCEV * S) const
  • public bool isSafeToExpandAt(const llvm::SCEV * S, const llvm::Instruction * InsertionPoint) const
  • private void rememberInstruction(llvm::Value * I)
  • public unsigned int replaceCongruentIVs(llvm::Loop * L, const llvm::DominatorTree * DT, SmallVectorImpl<llvm::WeakTrackingVH> & DeadInsts, const llvm::TargetTransformInfo * TTI = nullptr)
  • public void setChainedPhi(llvm::PHINode * PN)
  • public void setDebugType(const char * s)
  • public void setIVIncInsertPos(const llvm::Loop * L, llvm::Instruction * Pos)
  • public void setInsertPoint(llvm::Instruction * IP)
  • public void setPostInc(const llvm::PostIncLoopSet & L)
  • private llvm::Value * visitAddExpr(const llvm::SCEVAddExpr * S)
  • private llvm::Value * visitAddRecExpr(const llvm::SCEVAddRecExpr * S)
  • private llvm::Value * visitConstant(const llvm::SCEVConstant * S)
  • private llvm::Value * visitMulExpr(const llvm::SCEVMulExpr * S)
  • private llvm::Value * visitPtrToIntExpr(const llvm::SCEVPtrToIntExpr * S)
  • private llvm::Value * visitSMaxExpr(const llvm::SCEVSMaxExpr * S)
  • private llvm::Value * visitSMinExpr(const llvm::SCEVSMinExpr * S)
  • private llvm::Value * visitSequentialUMinExpr(const llvm::SCEVSequentialUMinExpr * S)
  • private llvm::Value * visitSignExtendExpr(const llvm::SCEVSignExtendExpr * S)
  • private llvm::Value * visitTruncateExpr(const llvm::SCEVTruncateExpr * S)
  • private llvm::Value * visitUDivExpr(const llvm::SCEVUDivExpr * S)
  • private llvm::Value * visitUMaxExpr(const llvm::SCEVUMaxExpr * S)
  • private llvm::Value * visitUMinExpr(const llvm::SCEVUMinExpr * S)
  • private llvm::Value * visitUnknown(const llvm::SCEVUnknown * S)
  • private llvm::Value * visitZeroExtendExpr(const llvm::SCEVZeroExtendExpr * S)
  • public ~SCEVExpander()

Methods

llvm::Value* FindValueInExprValueMap(
    const llvm::SCEV* S,
    const llvm::Instruction* InsertPt)

Description

Find a previous Value in ExprValueMap for expand.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:441

Parameters

const llvm::SCEV* S
const llvm::Instruction* InsertPt

BasicBlock::iterator
GetOptimalInsertionPointForCastOf(
    llvm::Value* V) const

Description

We want to cast \p V. What would be the best place for such a cast?

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:422

Parameters

llvm::Value* V

llvm::Value* InsertBinop(
    Instruction::BinaryOps Opcode,
    llvm::Value* LHS,
    llvm::Value* RHS,
    SCEV::NoWrapFlags Flags,
    bool IsSafeToHoist)

Description

Insert the specified binary operator, doing a small amount of work to avoid inserting an obviously redundant operation, and hoisting to an outer loop when the opportunity is there and it is safe.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:418

Parameters

Instruction::BinaryOps Opcode
llvm::Value* LHS
llvm::Value* RHS
SCEV::NoWrapFlags Flags
bool IsSafeToHoist

llvm::Value* InsertNoopCastOfTo(llvm::Value* V,
                                llvm::Type* Ty)

Description

Insert a cast of V to the specified type, which must be possible with a noop cast, doing what we can to share the casts.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:432

Parameters

llvm::Value* V
llvm::Type* Ty

llvm::Value* ReuseOrCreateCast(
    llvm::Value* V,
    llvm::Type* Ty,
    Instruction::CastOps Op,
    BasicBlock::iterator IP)

Description

Arrange for there to be a cast of V to Ty at IP, reusing an existing cast if a suitable one exists, moving an existing cast if a suitable one exists but isn't in the right place, or creating a new one.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:427

Parameters

llvm::Value* V
llvm::Type* Ty
Instruction::CastOps Op
BasicBlock::iterator IP

SCEVExpander(llvm::ScalarEvolution& se,
             const llvm::DataLayout& DL,
             const char* name,
             bool PreserveLCSSA = true)

Description

Construct a SCEVExpander in "canonical" mode.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:161

Parameters

llvm::ScalarEvolution& se
const llvm::DataLayout& DL
const char* name
bool PreserveLCSSA = true

void SetCurrentDebugLocation(llvm::DebugLoc L)

Description

Set location information used by debugging information.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:352

Parameters

llvm::DebugLoc L

void clear()

Description

Erase the contents of the InsertedExpressions map so that users trying to expand the same expression into multiple BasicBlocks or different places within the same BasicBlock can do so.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:186

void clearInsertPoint()

Description

Clear the current insertion point. This is useful if the instruction that had been serving as the insertion point may have been deleted.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:349

void clearPostInc()

Description

Disable all post-inc expansion.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:323

void disableCanonicalMode()

Description

Disable the behavior of expanding expressions in canonical form rather than in a more literal form. Non-canonical mode is useful for late optimization passes.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:334

void enableLSRMode()

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:336

llvm::Value* expand(const llvm::SCEV* S)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:443

Parameters

const llvm::SCEV* S

llvm::Value* expandAddRecExprLiterally(
    const llvm::SCEVAddRecExpr*)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:487

Parameters

const llvm::SCEVAddRecExpr*

llvm::Value* expandAddToGEP(
    const llvm::SCEV* Op,
    llvm::PointerType* PTy,
    llvm::Type* Ty,
    llvm::Value* V)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:438

Parameters

const llvm::SCEV* Op
llvm::PointerType* PTy
llvm::Type* Ty
llvm::Value* V

llvm::Value* expandAddToGEP(
    const llvm::SCEV* const* op_begin,
    const llvm::SCEV* const* op_end,
    llvm::PointerType* PTy,
    llvm::Type* Ty,
    llvm::Value* V)

Description

Expand a SCEVAddExpr with a pointer type into a GEP instead of using ptrtoint+arithmetic+inttoptr.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:436

Parameters

const llvm::SCEV* const* op_begin
const llvm::SCEV* const* op_end
llvm::PointerType* PTy
llvm::Type* Ty
llvm::Value* V

llvm::Value* expandCodeFor(
    const llvm::SCEV* SH,
    llvm::Type* Ty = nullptr)

Description

Insert code to directly compute the specified SCEV expression into the program. The code is inserted into the SCEVExpander's current insertion point. If a type is specified, the result will be expanded to have that type, with a cast if necessary.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:280

Parameters

const llvm::SCEV* SH
llvm::Type* Ty = nullptr

llvm::Value* expandCodeFor(const llvm::SCEV* SH,
                           llvm::Type* Ty,
                           llvm::Instruction* I)

Description

Insert code to directly compute the specified SCEV expression into the program. The code is inserted into the specified block.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:272

Parameters

const llvm::SCEV* SH
llvm::Type* Ty
llvm::Instruction* I

llvm::Value* expandCodeForImpl(
    const llvm::SCEV* SH,
    llvm::Type* Ty,
    llvm::Instruction* I,
    bool Root)

Description

Insert code to directly compute the specified SCEV expression into the program. The code is inserted into the specified block. If \p Root is true, this indicates that \p SH is the top-level expression to expand passed from an external client call.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:405

Parameters

const llvm::SCEV* SH
llvm::Type* Ty
llvm::Instruction* I
bool Root

llvm::Value* expandCodeForImpl(
    const llvm::SCEV* SH,
    llvm::Type* Ty,
    bool Root)

Description

Insert code to directly compute the specified SCEV expression into the program. The code is inserted into the SCEVExpander's current insertion point. If a type is specified, the result will be expanded to have that type, with a cast if necessary. If \p Root is true, this indicates that \p SH is the top-level expression to expand passed from an external client call.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:399

Parameters

const llvm::SCEV* SH
llvm::Type* Ty
bool Root

llvm::Value* expandCodeForPredicate(
    const llvm::SCEVPredicate* Pred,
    llvm::Instruction* Loc)

Description

Generates a code sequence that evaluates this predicate. The inserted instructions will be at position \p Loc. The result will be of type i1 and will have a value of 0 when the predicate is false and 1 otherwise.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:287

Parameters

const llvm::SCEVPredicate* Pred
llvm::Instruction* Loc

llvm::Value* expandComparePredicate(
    const llvm::SCEVComparePredicate* Pred,
    llvm::Instruction* Loc)

Description

A specialized variant of expandCodeForPredicate, handling the case when we are expanding code for a SCEVComparePredicate.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:291

Parameters

const llvm::SCEVComparePredicate* Pred
llvm::Instruction* Loc

llvm::Value* expandIVInc(llvm::PHINode* PN,
                         llvm::Value* StepV,
                         const llvm::Loop* L,
                         llvm::Type* ExpandTy,
                         llvm::Type* IntTy,
                         bool useSubtract)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:491

Parameters

llvm::PHINode* PN
llvm::Value* StepV
const llvm::Loop* L
llvm::Type* ExpandTy
llvm::Type* IntTy
bool useSubtract

llvm::Value* expandMinMaxExpr(
    const llvm::SCEVNAryExpr* S,
    Intrinsic::ID IntrinID,
    llvm::Twine Name,
    bool IsSequential = false)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:448

Parameters

const llvm::SCEVNAryExpr* S
Intrinsic::ID IntrinID
llvm::Twine Name
bool IsSequential = false

llvm::Value* expandUnionPredicate(
    const llvm::SCEVUnionPredicate* Pred,
    llvm::Instruction* Loc)

Description

A specialized variant of expandCodeForPredicate, handling the case when we are expanding code for a SCEVUnionPredicate.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:304

Parameters

const llvm::SCEVUnionPredicate* Pred
llvm::Instruction* Loc

llvm::Value* expandWrapPredicate(
    const llvm::SCEVWrapPredicate* P,
    llvm::Instruction* Loc)

Description

A specialized variant of expandCodeForPredicate, handling the case when we are expanding code for a SCEVWrapPredicate.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:300

Parameters

const llvm::SCEVWrapPredicate* P
llvm::Instruction* Loc

BasicBlock::iterator findInsertPointAfter(
    llvm::Instruction* I,
    llvm::Instruction* MustDominate) const

Description

Returns a suitable insert point after \p I, that dominates \p MustDominate. Skips instructions inserted by the expander.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:387

Parameters

llvm::Instruction* I
llvm::Instruction* MustDominate

void fixupInsertPoints(llvm::Instruction* I)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:494

Parameters

llvm::Instruction* I

llvm::Value* fixupLCSSAFormFor(
    llvm::Instruction* User,
    unsigned int OpIdx)

Description

If required, create LCSSA PHIs for \p Users' operand \p OpIdx. If new operand \p OpIdx. If new LCSSA PHIs have been created, return the LCSSA PHI available at \p User. If no PHIs have been created, return the unchanged operand \p OpIdx.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:499

Parameters

llvm::Instruction* User
unsigned int OpIdx

llvm::Value* generateOverflowCheck(
    const llvm::SCEVAddRecExpr* AR,
    llvm::Instruction* Loc,
    bool Signed)

Description

Generates code that evaluates if the \p AR expression will overflow.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:295

Parameters

const llvm::SCEVAddRecExpr* AR
llvm::Instruction* Loc
bool Signed

llvm::PHINode* getAddRecExprPHILiterally(
    const llvm::SCEVAddRecExpr* Normalized,
    const llvm::Loop* L,
    llvm::Type* ExpandTy,
    llvm::Type* IntTy,
    llvm::Type*& TruncTy,
    bool& InvertStep)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:488

Parameters

const llvm::SCEVAddRecExpr* Normalized
const llvm::Loop* L
llvm::Type* ExpandTy
llvm::Type* IntTy
llvm::Type*& TruncTy
bool& InvertStep

SmallVector<llvm::Instruction*, 32>
getAllInsertedInstructions() const

Description

Return a vector containing all instructions inserted during expansion.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:199

llvm::LLVMContext& getContext() const

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:391

llvm::DebugLoc getCurrentDebugLocation() const

Description

Get location information used by debugging information.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:357

llvm::Instruction* getIVIncOperand(
    llvm::Instruction* IncV,
    llvm::Instruction* InsertPos,
    bool allowScale)

Description

Return the induction variable increment's IV operand.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:248

Parameters

llvm::Instruction* IncV
llvm::Instruction* InsertPos
bool allowScale

const SmallVectorImpl<llvm::WeakVH>&
getInsertedIVs() const

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:196

llvm::Value* getRelatedExistingExpansion(
    const llvm::SCEV* S,
    const llvm::Instruction* At,
    llvm::Loop* L)

Description

Try to find the ValueOffsetPair for S. The function is mainly used to check whether S can be expanded cheaply. If this returns a non-None value, we know we can codegen the `ValueOffsetPair` into a suitable expansion identical with S so that S can be expanded cheaply. 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 an exhaustive search. I.e if it didn't find any value it does not mean that there is no such value.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:382

Parameters

const llvm::SCEV* S
const llvm::Instruction* At
llvm::Loop* L

const llvm::Loop* getRelevantLoop(
    const llvm::SCEV*)

Description

Determine the most "relevant" loop for the given SCEV.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:446

Parameters

const llvm::SCEV*

llvm::ScalarEvolution* getSE()

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:195

bool hoistIVInc(llvm::Instruction* IncV,
                llvm::Instruction* InsertPos)

Description

Utility for hoisting an IV increment.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:252

Parameters

llvm::Instruction* IncV
llvm::Instruction* InsertPos

bool isExpandedAddRecExprPHI(
    llvm::PHINode* PN,
    llvm::Instruction* IncV,
    const llvm::Loop* L)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:485

Parameters

llvm::PHINode* PN
llvm::Instruction* IncV
const llvm::Loop* L

bool isHighCostExpansion(
    const llvm::SCEV* Expr,
    llvm::Loop* L,
    unsigned int Budget,
    const llvm::TargetTransformInfo* TTI,
    const llvm::Instruction* At)

Description

Return true for expressions that can't be evaluated at runtime within given \b Budget. At is a parameter which specifies point in code where user is going to expand this expression. Sometimes this knowledge can lead to a less pessimistic cost estimation.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:225

Parameters

const llvm::SCEV* Expr
llvm::Loop* L
unsigned int Budget
const llvm::TargetTransformInfo* TTI
const llvm::Instruction* At

bool isHighCostExpansionHelper(
    const llvm::SCEVOperand& WorkItem,
    llvm::Loop* L,
    const llvm::Instruction& At,
    llvm::InstructionCost& Cost,
    unsigned int Budget,
    const llvm::TargetTransformInfo& TTI,
    SmallPtrSetImpl<const llvm::SCEV*>& Processed,
    SmallVectorImpl<llvm::SCEVOperand>& Worklist)

Description

Recursive helper function for isHighCostExpansion.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:408

Parameters

const llvm::SCEVOperand& WorkItem
llvm::Loop* L
const llvm::Instruction& At
llvm::InstructionCost& Cost
unsigned int Budget
const llvm::TargetTransformInfo& TTI
SmallPtrSetImpl<const llvm::SCEV*>& Processed
SmallVectorImpl<llvm::SCEVOperand>& Worklist

bool isInsertedInstruction(
    llvm::Instruction* I) const

Description

Return true if the specified instruction was inserted by the code rewriter. If so, the client should not modify the instruction. Note that this also includes instructions re-used during expansion.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:364

Parameters

llvm::Instruction* I

bool isNormalAddRecExprPHI(
    llvm::PHINode* PN,
    llvm::Instruction* IncV,
    const llvm::Loop* L)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:483

Parameters

llvm::PHINode* PN
llvm::Instruction* IncV
const llvm::Loop* L

bool isSafeToExpand(const llvm::SCEV* S) const

Description

Return true if the given expression is safe to expand in the sense that all materialized values are safe to speculate anywhere their operands are defined, and the expander is capable of expanding the expression.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:263

Parameters

const llvm::SCEV* S

bool isSafeToExpandAt(
    const llvm::SCEV* S,
    const llvm::Instruction* InsertionPoint) const

Description

Return true if the given expression is safe to expand in the sense that all materialized values are defined and safe to speculate at the specified location and their operands are defined at this location.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:268

Parameters

const llvm::SCEV* S
const llvm::Instruction* InsertionPoint

void rememberInstruction(llvm::Value* I)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:481

Parameters

llvm::Value* I

unsigned int replaceCongruentIVs(
    llvm::Loop* L,
    const llvm::DominatorTree* DT,
    SmallVectorImpl<llvm::WeakTrackingVH>&
        DeadInsts,
    const llvm::TargetTransformInfo* TTI =
        nullptr)

Description

replace congruent phis with their most canonical representative. Return the number of phis eliminated.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:256

Parameters

llvm::Loop* L
const llvm::DominatorTree* DT
SmallVectorImpl<llvm::WeakTrackingVH>& DeadInsts
const llvm::TargetTransformInfo* TTI = nullptr

void setChainedPhi(llvm::PHINode* PN)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:368

Parameters

llvm::PHINode* PN

void setDebugType(const char* s)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:180

Parameters

const char* s

void setIVIncInsertPos(const llvm::Loop* L,
                       llvm::Instruction* Pos)

Description

Set the current IV increment loop and position.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:307

Parameters

const llvm::Loop* L
llvm::Instruction* Pos

void setInsertPoint(llvm::Instruction* IP)

Description

Set the current insertion point. This is useful if multiple calls to expandCodeFor() are going to be made with the same insert point and the insert point may be moved during one of the expansions (e.g. if the insert point is not a block terminator).

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:342

Parameters

llvm::Instruction* IP

void setPostInc(const llvm::PostIncLoopSet& L)

Description

Enable post-inc expansion for addrecs referring to the given loops. Post-inc expansion is only supported in non-canonical mode.

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:316

Parameters

const llvm::PostIncLoopSet& L

llvm::Value* visitAddExpr(
    const llvm::SCEVAddExpr* S)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:461

Parameters

const llvm::SCEVAddExpr* S

llvm::Value* visitAddRecExpr(
    const llvm::SCEVAddRecExpr* S)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:467

Parameters

const llvm::SCEVAddRecExpr* S

llvm::Value* visitConstant(
    const llvm::SCEVConstant* S)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:451

Parameters

const llvm::SCEVConstant* S

llvm::Value* visitMulExpr(
    const llvm::SCEVMulExpr* S)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:463

Parameters

const llvm::SCEVMulExpr* S

llvm::Value* visitPtrToIntExpr(
    const llvm::SCEVPtrToIntExpr* S)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:453

Parameters

const llvm::SCEVPtrToIntExpr* S

llvm::Value* visitSMaxExpr(
    const llvm::SCEVSMaxExpr* S)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:469

Parameters

const llvm::SCEVSMaxExpr* S

llvm::Value* visitSMinExpr(
    const llvm::SCEVSMinExpr* S)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:473

Parameters

const llvm::SCEVSMinExpr* S

llvm::Value* visitSequentialUMinExpr(
    const llvm::SCEVSequentialUMinExpr* S)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:477

Parameters

const llvm::SCEVSequentialUMinExpr* S

llvm::Value* visitSignExtendExpr(
    const llvm::SCEVSignExtendExpr* S)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:459

Parameters

const llvm::SCEVSignExtendExpr* S

llvm::Value* visitTruncateExpr(
    const llvm::SCEVTruncateExpr* S)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:455

Parameters

const llvm::SCEVTruncateExpr* S

llvm::Value* visitUDivExpr(
    const llvm::SCEVUDivExpr* S)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:465

Parameters

const llvm::SCEVUDivExpr* S

llvm::Value* visitUMaxExpr(
    const llvm::SCEVUMaxExpr* S)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:471

Parameters

const llvm::SCEVUMaxExpr* S

llvm::Value* visitUMinExpr(
    const llvm::SCEVUMinExpr* S)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:475

Parameters

const llvm::SCEVUMinExpr* S

llvm::Value* visitUnknown(
    const llvm::SCEVUnknown* S)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:479

Parameters

const llvm::SCEVUnknown* S

llvm::Value* visitZeroExtendExpr(
    const llvm::SCEVZeroExtendExpr* S)

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:457

Parameters

const llvm::SCEVZeroExtendExpr* S

~SCEVExpander()

Declared at: llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:174