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/Analysis/ScalarEvolutionExpander.h:45

Inherits from: SCEVVisitor

Method Overview

Methods

SCEVExpander(llvm::ScalarEvolution& se,
             const llvm::DataLayout& DL,
             const char* name)

Description

Construct a SCEVExpander in "canonical" mode.

Declared at: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:145

Parameters

llvm::ScalarEvolution& se
const llvm::DataLayout& DL
const char* name

void SetCurrentDebugLocation(llvm::DebugLoc L)

Description

Set location information used by debugging information.

Declared at: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:285

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/Analysis/ScalarEvolutionExpander.h:167

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/Analysis/ScalarEvolutionExpander.h:282

void clearPostInc()

Description

Disable all post-inc expansion.

Declared at: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:256

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/Analysis/ScalarEvolutionExpander.h:267

void enableLSRMode()

Declared at: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:269

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 inserted code is inserted into the specified block.

Declared at: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:207

Parameters

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

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 inserted 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/Analysis/ScalarEvolutionExpander.h:213

Parameters

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

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/Analysis/ScalarEvolutionExpander.h:219

Parameters

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

llvm::Value* expandEqualPredicate(
    const llvm::SCEVEqualPredicate* Pred,
    llvm::Instruction* Loc)

Description

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

Declared at: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:223

Parameters

const llvm::SCEVEqualPredicate* Pred
llvm::Instruction* Loc

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/Analysis/ScalarEvolutionExpander.h:236

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/Analysis/ScalarEvolutionExpander.h:232

Parameters

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

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/Analysis/ScalarEvolutionExpander.h:227

Parameters

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

const llvm::DebugLoc& getCurrentDebugLocation()
    const

Description

Get location information used by debugging information.

Declared at: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:290

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

Description

Try to find existing LLVM IR value for S available at the point At.

Declared at: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:303

Parameters

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

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/Analysis/ScalarEvolutionExpander.h:193

Parameters

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

llvm::PHINode*
getOrInsertCanonicalInductionVariable(
    const llvm::Loop* L,
    llvm::Type* Ty)

Description

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 starts at zero and steps by one on each iteration.

Declared at: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:190

Parameters

const llvm::Loop* L
llvm::Type* Ty

Optional<ScalarEvolution::ValueOffsetPair>
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/Analysis/ScalarEvolutionExpander.h:319

Parameters

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

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

Description

Utility for hoisting an IV increment.

Declared at: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:197

Parameters

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

bool isHighCostExpansion(
    const llvm::SCEV* Expr,
    llvm::Loop* L,
    const llvm::Instruction* At = nullptr)

Description

Return true for expressions that may incur non-trivial cost to evaluate at runtime. 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.

Declared at: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:180

Parameters

const llvm::SCEV* Expr
llvm::Loop* L
const llvm::Instruction* At = nullptr

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.

Declared at: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:296

Parameters

llvm::Instruction* 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/Analysis/ScalarEvolutionExpander.h:201

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/Analysis/ScalarEvolutionExpander.h:300

Parameters

llvm::PHINode* PN

void setDebugType(const char* s)

Declared at: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:161

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/Analysis/ScalarEvolutionExpander.h:240

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/Analysis/ScalarEvolutionExpander.h:275

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/Analysis/ScalarEvolutionExpander.h:249

Parameters

const llvm::PostIncLoopSet& L

~SCEVExpander()

Declared at: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:155