LLVM  14.0.0git
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
llvm::SCEV Class Reference

This class represents an analyzed expression in the program. More...

#include "llvm/Analysis/ScalarEvolution.h"

Inheritance diagram for llvm::SCEV:
Inheritance graph
[legend]
Collaboration diagram for llvm::SCEV:
Collaboration graph
[legend]

Public Types

enum  NoWrapFlags {
  FlagAnyWrap = 0, FlagNW = (1 << 0), FlagNUW = (1 << 1), FlagNSW = (1 << 2),
  NoWrapMask = (1 << 3) - 1
}
 NoWrapFlags are bitfield indices into SubclassData. More...
 

Public Member Functions

 SCEV (const FoldingSetNodeIDRef ID, SCEVTypes SCEVTy, unsigned short ExpressionSize)
 
 SCEV (const SCEV &)=delete
 
SCEVoperator= (const SCEV &)=delete
 
SCEVTypes getSCEVType () const
 
TypegetType () const
 Return the LLVM type of this SCEV expression. More...
 
bool isZero () const
 Return true if the expression is a constant zero. More...
 
bool isOne () const
 Return true if the expression is a constant one. More...
 
bool isAllOnesValue () const
 Return true if the expression is a constant all-ones value. More...
 
bool isNonConstantNegative () const
 Return true if the specified scev is negated, but not a constant. More...
 
unsigned short getExpressionSize () const
 
void print (raw_ostream &OS) const
 Print out the internal representation of this scalar to the specified stream. More...
 
void dump () const
 This method is used for debugging. More...
 
- Public Member Functions inherited from llvm::FoldingSetBase::Node
 Node ()=default
 
void * getNextInBucket () const
 
void SetNextInBucket (void *N)
 

Protected Attributes

const unsigned short ExpressionSize
 
unsigned short SubclassData = 0
 This field is initialized to zero and may be used in subclasses to store miscellaneous information. More...
 

Friends

struct FoldingSetTrait< SCEV >
 

Detailed Description

This class represents an analyzed expression in the program.

These are opaque objects that the client is not allowed to do much with directly.

Definition at line 77 of file ScalarEvolution.h.

Member Enumeration Documentation

◆ NoWrapFlags

NoWrapFlags are bitfield indices into SubclassData.

Add and Mul expressions may have no-unsigned-wrap <NUW> or no-signed-wrap <NSW> properties, which are derived from the IR operator. NSW is a misnomer that we use to mean no signed overflow or underflow.

AddRec expressions may have a no-self-wraparound <NW> property if, in the integer domain, abs(step) * max-iteration(loop) <= unsigned-max(bitwidth). This means that the recurrence will never reach its start value if the step is non-zero. Computing the same value on each iteration is not considered wrapping, and recurrences with step = 0 are trivially <NW>. <NW> is independent of the sign of step and the value the add recurrence starts with.

Note that NUW and NSW are also valid properties of a recurrence, and either implies NW. For convenience, NW will be set for a recurrence whenever either NUW or NSW are set.

We require that the flag on a SCEV apply to the entire scope in which that SCEV is defined. A SCEV's scope is set of locations dominated by a defining location, which is in turn described by the following rules:

  • A SCEVUnknown is at the point of definition of the Value.
  • A SCEVConstant is defined at all points.
  • A SCEVAddRec is defined starting with the header of the associated loop.
  • All other SCEVs are defined at the earlest point all operands are defined.

The above rules describe a maximally hoisted form (without regards to potential control dependence). A SCEV is defined anywhere a corresponding instruction could be defined in said maximally hoisted form. Note that SCEVUDivExpr (currently the only expression type which can trap) can be defined per these rules in regions where it would trap at runtime. A SCEV being defined does not require the existence of any instruction within the defined scope.

Enumerator
FlagAnyWrap 
FlagNW 
FlagNUW 
FlagNSW 
NoWrapMask 

Definition at line 132 of file ScalarEvolution.h.

Constructor & Destructor Documentation

◆ SCEV() [1/2]

llvm::SCEV::SCEV ( const FoldingSetNodeIDRef  ID,
SCEVTypes  SCEVTy,
unsigned short  ExpressionSize 
)
inlineexplicit

Definition at line 140 of file ScalarEvolution.h.

◆ SCEV() [2/2]

llvm::SCEV::SCEV ( const SCEV )
delete

Member Function Documentation

◆ dump()

LLVM_DUMP_METHOD void SCEV::dump ( ) const

This method is used for debugging.

Definition at line 245 of file ScalarEvolution.cpp.

References llvm::dbgs(), and print().

◆ getExpressionSize()

unsigned short llvm::SCEV::getExpressionSize ( ) const
inline

Definition at line 172 of file ScalarEvolution.h.

References ExpressionSize.

Referenced by RewriteDVIUsingIterCount().

◆ getSCEVType()

SCEVTypes llvm::SCEV::getSCEVType ( ) const
inline

◆ getType()

Type * SCEV::getType ( ) const

Return the LLVM type of this SCEV expression.

Definition at line 379 of file ScalarEvolution.cpp.

References llvm_unreachable, llvm::scAddExpr, llvm::scAddRecExpr, llvm::scConstant, llvm::scCouldNotCompute, llvm::scMulExpr, llvm::scPtrToInt, llvm::scSignExtend, llvm::scSMaxExpr, llvm::scSMinExpr, llvm::scTruncate, llvm::scUDivExpr, llvm::scUMaxExpr, llvm::scUMinExpr, llvm::scUnknown, and llvm::scZeroExtend.

Referenced by llvm::SCEVAAResult::alias(), BinomialCoefficient(), llvm::ScalarEvolution::computeConstantDifference(), llvm::LoopVectorizationCostModel::computeMaxVF(), llvm::IndexedReference::computeRefCost(), countToEliminateCompares(), llvm::InnerLoopVectorizer::createInductionResumeValues(), WidenIV::createWideIV(), DoInitialMatch(), llvm::SCEVExpander::expandEqualPredicate(), FactorOutConstant(), FindLoopCounter(), llvm::InnerLoopVectorizer::fixupIVUsers(), genLoopLimit(), llvm::ScalarEvolution::getAnyExtendExpr(), llvm::ScalarEvolution::getEqualPredicate(), getExactSDiv(), llvm::ScalarEvolution::getGEPExpr(), llvm::ScalarEvolution::getLoopInvariantExitCondDuringFirstIterations(), llvm::ScalarEvolution::getLosslessPtrToIntExpr(), llvm::ScalarEvolution::getMinusSCEV(), llvm::ScalarEvolution::getNegativeSCEV(), getNewAlignment(), llvm::ScalarEvolution::getNoopOrAnyExtend(), llvm::ScalarEvolution::getNoopOrSignExtend(), llvm::ScalarEvolution::getNoopOrZeroExtend(), llvm::ScalarEvolution::getNotSCEV(), llvm::InnerLoopVectorizer::getOrCreateTripCount(), llvm::ScalarEvolution::getPointerBase(), getSignedOverflowLimitForStep(), getTripCount(), llvm::ScalarEvolution::getTripCountFromExitCount(), llvm::ScalarEvolution::getTruncateOrNoop(), llvm::ScalarEvolution::getTruncateOrSignExtend(), llvm::ScalarEvolution::getTruncateOrZeroExtend(), llvm::SCEVMulExpr::getType(), llvm::SCEVUDivExpr::getType(), llvm::SCEVAddRecExpr::getType(), llvm::SCEVMinMaxExpr::getType(), llvm::ScalarEvolution::getUDivExpr(), llvm::ScalarEvolution::getUMaxFromMismatchedTypes(), getUnsignedOverflowLimitForStep(), llvm::ScalarEvolution::getURemExpr(), WidenIV::getWideRecurrence(), llvm::hasIterationCountInvariantInParent(), llvm::ARMTTIImpl::isHardwareLoopProfitable(), llvm::ScalarEvolution::isLoopBackedgeGuardedByCond(), isSafeDependenceDistance(), optimizeLoopExitWithUnknownExitCount(), WidenIV::pushNarrowIVUsers(), llvm::SCEVEqualPredicate::SCEVEqualPredicate(), llvm::ScalarEvolution::SimplifyICmpOperands(), llvm::splitLoopBound(), llvm::UnrollRuntimeLoopRemainder(), llvm::SCEVDivision::visitAddExpr(), llvm::SCEVDivision::visitAddRecExpr(), llvm::SCEVDivision::visitMulExpr(), llvm::InnerLoopVectorizer::widenPHIInstruction(), and llvm::ScalarEvolution::willNotOverflow().

◆ isAllOnesValue()

bool SCEV::isAllOnesValue ( ) const

Return true if the expression is a constant all-ones value.

Definition at line 421 of file ScalarEvolution.cpp.

References llvm::PPCISD::SC.

Referenced by MatchNotExpr().

◆ isNonConstantNegative()

bool SCEV::isNonConstantNegative ( ) const

Return true if the specified scev is negated, but not a constant.

Definition at line 427 of file ScalarEvolution.cpp.

References llvm::Mul, and llvm::PPCISD::SC.

◆ isOne()

bool SCEV::isOne ( ) const

Return true if the expression is a constant one.

Definition at line 415 of file ScalarEvolution.cpp.

References llvm::PPCISD::SC.

Referenced by llvm::SCEVDivision::divide(), FactorOutConstant(), genLoopLimit(), and isLoopCounter().

◆ isZero()

bool SCEV::isZero ( ) const

◆ operator=()

SCEV& llvm::SCEV::operator= ( const SCEV )
delete

◆ print()

void SCEV::print ( raw_ostream OS) const

Friends And Related Function Documentation

◆ FoldingSetTrait< SCEV >

friend struct FoldingSetTrait< SCEV >
friend

Definition at line 78 of file ScalarEvolution.h.

Member Data Documentation

◆ ExpressionSize

const unsigned short llvm::SCEV::ExpressionSize
protected

Definition at line 89 of file ScalarEvolution.h.

Referenced by getExpressionSize().

◆ SubclassData

unsigned short llvm::SCEV::SubclassData = 0
protected

This field is initialized to zero and may be used in subclasses to store miscellaneous information.

Definition at line 93 of file ScalarEvolution.h.

Referenced by llvm::SCEVNAryExpr::getNoWrapFlags(), llvm::SCEVCommutativeExpr::setNoWrapFlags(), and llvm::SCEVAddRecExpr::setNoWrapFlags().


The documentation for this class was generated from the following files: