LLVM 20.0.0git
|
This class represents an analyzed expression in the program. More...
#include "llvm/Analysis/ScalarEvolution.h"
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 | |
SCEV & | operator= (const SCEV &)=delete |
SCEVTypes | getSCEVType () const |
Type * | getType () const |
Return the LLVM type of this SCEV expression. | |
ArrayRef< const SCEV * > | operands () const |
Return operands of this SCEV expression. | |
bool | isZero () const |
Return true if the expression is a constant zero. | |
bool | isOne () const |
Return true if the expression is a constant one. | |
bool | isAllOnesValue () const |
Return true if the expression is a constant all-ones value. | |
bool | isNonConstantNegative () const |
Return true if the specified scev is negated, but not a constant. | |
unsigned short | getExpressionSize () const |
void | print (raw_ostream &OS) const |
Print out the internal representation of this scalar to the specified stream. | |
void | dump () const |
This method is used for debugging. | |
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. | |
Friends | |
struct | FoldingSetTrait< SCEV > |
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 71 of file ScalarEvolution.h.
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:
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 126 of file ScalarEvolution.h.
|
inlineexplicit |
Definition at line 134 of file ScalarEvolution.h.
LLVM_DUMP_METHOD void SCEV::dump | ( | ) | const |
This method is used for debugging.
Definition at line 261 of file ScalarEvolution.cpp.
References llvm::dbgs(), and print().
|
inline |
Definition at line 169 of file ScalarEvolution.h.
References ExpressionSize.
Referenced by hasHugeExpression().
|
inline |
Definition at line 140 of file ScalarEvolution.h.
Referenced by llvm::SCEVCouldNotCompute::classof(), llvm::SCEVConstant::classof(), llvm::SCEVVScale::classof(), llvm::SCEVCastExpr::classof(), llvm::SCEVPtrToIntExpr::classof(), llvm::SCEVIntegralCastExpr::classof(), llvm::SCEVTruncateExpr::classof(), llvm::SCEVZeroExtendExpr::classof(), llvm::SCEVSignExtendExpr::classof(), llvm::SCEVNAryExpr::classof(), llvm::SCEVCommutativeExpr::classof(), llvm::SCEVAddExpr::classof(), llvm::SCEVMulExpr::classof(), llvm::SCEVUDivExpr::classof(), llvm::SCEVAddRecExpr::classof(), llvm::SCEVMinMaxExpr::classof(), llvm::SCEVSMaxExpr::classof(), llvm::SCEVUMaxExpr::classof(), llvm::SCEVSMinExpr::classof(), llvm::SCEVUMinExpr::classof(), llvm::SCEVSequentialMinMaxExpr::classof(), llvm::SCEVSequentialUMinExpr::classof(), llvm::SCEVUnknown::classof(), llvm::SCEVSequentialMinMaxExpr::getEquivalentNonSequentialSCEVType(), getExprBase(), getType(), GroupByComplexity(), isHighCostExpansion(), operands(), print(), SCEVMinMaxExprContains(), llvm::SCEVVisitor< SC, RetVal >::visit(), and llvm::SCEVTraversal< SV >::visitAll().
Type * SCEV::getType | ( | ) | const |
Return the LLVM type of this SCEV expression.
Definition at line 380 of file ScalarEvolution.cpp.
References getSCEVType(), llvm_unreachable, llvm::scAddExpr, llvm::scAddRecExpr, llvm::scConstant, llvm::scCouldNotCompute, llvm::scMulExpr, llvm::scPtrToInt, llvm::scSequentialUMinExpr, llvm::scSignExtend, llvm::scSMaxExpr, llvm::scSMinExpr, llvm::scTruncate, llvm::scUDivExpr, llvm::scUMaxExpr, llvm::scUMinExpr, llvm::scUnknown, llvm::scVScale, and llvm::scZeroExtend.
Referenced by llvm::SCEVAAResult::alias(), BinomialCoefficient(), calculateRtStride(), llvm::cannotBeMaxInLoop(), llvm::cannotBeMinInLoop(), llvm::ScalarEvolution::computeConstantDifference(), llvm::LoopVectorizationCostModel::computeMaxVF(), llvm::IndexedReference::computeRefCost(), computeTripCount(), countToEliminateCompares(), llvm::VPlan::createInitialVPlan(), createNodeForSelectViaUMinSeq(), createReplacement(), DoInitialMatch(), llvm::VPWidenPointerInductionRecipe::execute(), llvm::VPExpandSCEVRecipe::execute(), llvm::ScalarEvolution::ExitLimit::ExitLimit(), expandBounds(), llvm::SCEVExpander::expandCodeFor(), findForkedSCEVs(), FindLoopCounter(), llvm::SCEVExpander::generateOverflowCheck(), genLoopLimit(), llvm::ScalarEvolution::getAnyExtendExpr(), llvm::ScalarEvolution::getGEPExpr(), llvm::ScalarEvolution::getLoopInvariantExitCondDuringFirstIterationsImpl(), llvm::ScalarEvolution::getLosslessPtrToIntExpr(), llvm::ScalarEvolution::getMinTrailingZeros(), getNewAlignment(), getSignedOverflowLimitForStep(), llvm::ScalarEvolution::getSignExtendExprImpl(), getStartAndEndForAccess(), llvm::ScalarEvolution::getTripCountFromExitCount(), llvm::SCEVMulExpr::getType(), llvm::SCEVUDivExpr::getType(), llvm::SCEVAddRecExpr::getType(), llvm::SCEVMinMaxExpr::getType(), llvm::SCEVSequentialMinMaxExpr::getType(), llvm::ScalarEvolution::getUMinFromMismatchedTypes(), getUnsignedOverflowLimitForStep(), llvm::ScalarEvolution::getZeroExtendExprImpl(), llvm::hasIterationCountInvariantInParent(), llvm::ARMTTIImpl::isHardwareLoopProfitable(), llvm::isKnownNegativeInLoop(), llvm::isKnownNonNegativeInLoop(), llvm::isKnownNonPositiveInLoop(), llvm::isKnownPositiveInLoop(), llvm::ScalarEvolution::isLoopBackedgeGuardedByCond(), isSafeDecreasingBound(), isSafeDependenceDistance(), isSafeIncreasingBound(), IsSimplerBaseSCEVForTarget(), llvm::VPlanTransforms::optimizeForVFAndUF(), optimizeLoopExitWithUnknownExitCount(), llvm::LoopStructure::parseLoopStructure(), PrintSCEVWithTypeHint(), llvm::replaceSymbolicStrideSCEV(), llvm::splitLoopBound(), llvm::UnrollRuntimeLoopRemainder(), verifyTripCount(), llvm::SCEVDivision::visitAddExpr(), llvm::SCEVDivision::visitAddRecExpr(), and llvm::SCEVDivision::visitMulExpr().
bool SCEV::isAllOnesValue | ( | ) | const |
Return true if the expression is a constant all-ones value.
Definition at line 454 of file ScalarEvolution.cpp.
Referenced by MatchNotExpr().
bool SCEV::isNonConstantNegative | ( | ) | const |
Return true if the specified scev is negated, but not a constant.
Definition at line 460 of file ScalarEvolution.cpp.
References llvm::Mul.
Referenced by calculateRtStride().
bool SCEV::isOne | ( | ) | const |
Return true if the expression is a constant one.
Definition at line 448 of file ScalarEvolution.cpp.
Referenced by llvm::SCEVDivision::divide(), llvm::SCEVExpander::generateOverflowCheck(), genLoopLimit(), llvm::LoopVectorizationCostModel::getInstructionCost(), getStartForNegStride(), and isLoopCounter().
bool SCEV::isZero | ( | ) | const |
Return true if the expression is a constant zero.
Definition at line 442 of file ScalarEvolution.cpp.
Referenced by breakBackedgeIfNotTaken(), calculateRtStride(), llvm::ScalarEvolution::LoopGuards::collect(), CollectSubexprs(), llvm::LoopVectorizationCostModel::computeMaxVF(), llvm::SCEVDivision::divide(), llvm::ScalarEvolution::ExitLimit::ExitLimit(), llvm::findArrayDimensions(), FindLoopCounter(), isAlwaysFoldable(), llvm::VPlanTransforms::optimizeForVFAndUF(), SolveQuadraticAddRecRange(), llvm::ScalarEvolution::verify(), and llvm::SCEVDivision::visitMulExpr().
Return operands of this SCEV expression.
Definition at line 414 of file ScalarEvolution.cpp.
References getSCEVType(), llvm_unreachable, llvm::scAddExpr, llvm::scAddRecExpr, llvm::scConstant, llvm::scCouldNotCompute, llvm::scMulExpr, llvm::scPtrToInt, llvm::scSequentialUMinExpr, llvm::scSignExtend, llvm::scSMaxExpr, llvm::scSMinExpr, llvm::scTruncate, llvm::scUDivExpr, llvm::scUMaxExpr, llvm::scUMinExpr, llvm::scUnknown, llvm::scVScale, and llvm::scZeroExtend.
Referenced by llvm::ScalarEvolution::LoopGuards::collect(), llvm::ScalarEvolution::computeConstantDifference(), llvm::ScalarEvolution::getMulExpr(), llvm::ScalarEvolution::getNotSCEV(), getSetupCost(), llvm::ScalarEvolution::verify(), and llvm::SCEVTraversal< SV >::visitAll().
void SCEV::print | ( | raw_ostream & | OS | ) | const |
Print out the internal representation of this scalar to the specified stream.
This should really only be used for debugging purposes.
Definition at line 267 of file ScalarEvolution.cpp.
References FlagNSW, FlagNUW, llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::SCEVUDivExpr::getLHS(), llvm::SCEVAddRecExpr::getLoop(), llvm::SCEVNAryExpr::getNoWrapFlags(), llvm::SCEVNAryExpr::getNumOperands(), llvm::SCEVCastExpr::getOperand(), llvm::SCEVNAryExpr::getOperand(), llvm::SCEVUDivExpr::getRHS(), getSCEVType(), llvm::SCEVCastExpr::getType(), llvm::SCEVNAryExpr::hasNoSelfWrap(), llvm::SCEVNAryExpr::hasNoSignedWrap(), llvm::SCEVNAryExpr::hasNoUnsignedWrap(), llvm_unreachable, llvm::SCEVNAryExpr::operands(), OS, llvm::Value::printAsOperand(), llvm::scAddExpr, llvm::scAddRecExpr, llvm::scConstant, llvm::scCouldNotCompute, llvm::scMulExpr, llvm::scPtrToInt, llvm::scSequentialUMinExpr, llvm::scSignExtend, llvm::scSMaxExpr, llvm::scSMinExpr, llvm::scTruncate, llvm::scUDivExpr, llvm::scUMaxExpr, llvm::scUMinExpr, llvm::scUnknown, llvm::scVScale, and llvm::scZeroExtend.
Referenced by dump(), llvm::operator<<(), and llvm::ScalarEvolution::print().
|
friend |
Definition at line 412 of file ScalarEvolution.h.
Definition at line 83 of file ScalarEvolution.h.
Referenced by getExpressionSize().
|
protected |
This field is initialized to zero and may be used in subclasses to store miscellaneous information.
Definition at line 87 of file ScalarEvolution.h.
Referenced by llvm::SCEVNAryExpr::getNoWrapFlags(), llvm::SCEVCommutativeExpr::setNoWrapFlags(), and llvm::SCEVAddRecExpr::setNoWrapFlags().