class PredicatedScalarEvolution

Declaration

class PredicatedScalarEvolution { /* full declaration omitted */ };

Description

An interface layer with SCEV used to manage how we see SCEV expressions for values in the context of existing predicates. We can add new predicates, but we cannot remove them. This layer has multiple purposes: - provides a simple interface for SCEV versioning. - guarantees that the order of transformations applied on a SCEV expression for a single Value is consistent across two different getSCEV calls. This means that, for example, once we've obtained an AddRec expression for a certain value through expression rewriting, we will continue to get an AddRec expression for that Value. - lowers the number of expression rewrites.

Declared at: llvm/include/llvm/Analysis/ScalarEvolution.h:2186

Member Variables

private DenseMap< const llvm::SCEV*, llvm::PredicatedScalarEvolution::RewriteEntry> RewriteMap
Maps a SCEV to the rewrite result of that SCEV at a certain version number. If this number doesn't match the current Generation, we will need to do a rewrite. To preserve the transformation order of previous rewrites, we will rewrite the previous result instead of the original SCEV.
private ValueMap<llvm::Value*, SCEVWrapPredicate::IncrementWrapFlags> FlagsMap
Records what NoWrap flags we've added to a Value *.
private llvm::ScalarEvolution& SE
The ScalarEvolution analysis.
private const llvm::Loop& L
The analyzed Loop.
private std::unique_ptr<SCEVUnionPredicate> Preds
The SCEVPredicate that forms our context. We will rewrite all expressions assuming that this predicate true.
private unsigned int Generation = 0
Marks the version of the SCEV predicate used. When rewriting a SCEV expression we mark it with the version of the predicate. We use this to figure out if the predicate has changed from the last rewrite of the SCEV. If so, we need to perform a new rewrite.
private const llvm::SCEV* BackedgeCount = nullptr
The backedge taken count.

Method Overview

Methods

PredicatedScalarEvolution(
    llvm::ScalarEvolution& SE,
    llvm::Loop& L)

Declared at: llvm/include/llvm/Analysis/ScalarEvolution.h:2188

Parameters

llvm::ScalarEvolution& SE
llvm::Loop& L

PredicatedScalarEvolution(
    const llvm::PredicatedScalarEvolution&)

Description

We need to explicitly define the copy constructor because of FlagsMap.

Declared at: llvm/include/llvm/Analysis/ScalarEvolution.h:2221

Parameters

const llvm::PredicatedScalarEvolution&

void addPredicate(const llvm::SCEVPredicate& Pred)

Description

Adds a new predicate.

Declared at: llvm/include/llvm/Analysis/ScalarEvolution.h:2202

Parameters

const llvm::SCEVPredicate& Pred

bool areAddRecsEqualWithPreds(
    const llvm::SCEVAddRecExpr* AR1,
    const llvm::SCEVAddRecExpr* AR2) const

Description

Check if \p AR1 and \p AR2 are equal, while taking into account Equal predicates in Preds.

Declared at: llvm/include/llvm/Analysis/ScalarEvolution.h:2229

Parameters

const llvm::SCEVAddRecExpr* AR1
const llvm::SCEVAddRecExpr* AR2

const llvm::SCEVAddRecExpr* getAsAddRec(
    llvm::Value* V)

Description

Attempts to produce an AddRecExpr for V by adding additional SCEV predicates. If we can't transform the expression into an AddRecExpr we return nullptr and not add additional SCEV predicates to the current context.

Declared at: llvm/include/llvm/Analysis/ScalarEvolution.h:2208

Parameters

llvm::Value* V

const llvm::SCEV* getBackedgeTakenCount()

Description

Get the (predicated) backedge count for the analyzed loop.

Declared at: llvm/include/llvm/Analysis/ScalarEvolution.h:2199

const llvm::SCEVPredicate& getPredicate() const

Declared at: llvm/include/llvm/Analysis/ScalarEvolution.h:2190

const llvm::SCEV* getSCEV(llvm::Value* V)

Description

Returns the SCEV expression of V, in the context of the current SCEV predicate. The order of transformations applied on the expression of V returned by ScalarEvolution is guaranteed to be preserved, even when adding new predicates.

Declared at: llvm/include/llvm/Analysis/ScalarEvolution.h:2196

Parameters

llvm::Value* V

llvm::ScalarEvolution* getSE() const

Description

Returns the ScalarEvolution analysis used.

Declared at: llvm/include/llvm/Analysis/ScalarEvolution.h:2218

bool hasNoOverflow(
    llvm::Value* V,
    SCEVWrapPredicate::IncrementWrapFlags Flags)

Description

Returns true if we've proved that V doesn't wrap by means of a SCEV predicate.

Declared at: llvm/include/llvm/Analysis/ScalarEvolution.h:2215

Parameters

llvm::Value* V
SCEVWrapPredicate::IncrementWrapFlags Flags

void print(llvm::raw_ostream& OS,
           unsigned int Depth) const

Description

Print the SCEV mappings done by the Predicated Scalar Evolution. The printed text is indented by \p Depth.

Declared at: llvm/include/llvm/Analysis/ScalarEvolution.h:2225

Parameters

llvm::raw_ostream& OS
unsigned int Depth

void setNoOverflow(
    llvm::Value* V,
    SCEVWrapPredicate::IncrementWrapFlags Flags)

Description

Proves that V doesn't overflow by adding SCEV predicate.

Declared at: llvm/include/llvm/Analysis/ScalarEvolution.h:2211

Parameters

llvm::Value* V
SCEVWrapPredicate::IncrementWrapFlags Flags

void updateGeneration()

Description

Increments the version number of the predicate. This needs to be called every time the SCEV predicate changes.

Declared at: llvm/include/llvm/Analysis/ScalarEvolution.h:2235