LLVM  8.0.1
Public Types | Public Member Functions | Static Public Member Functions | List of all members
llvm::SCEVWrapPredicate Class Referencefinal

This class represents an assumption made on an AddRec expression. More...

#include "llvm/Analysis/ScalarEvolution.h"

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

Public Types

enum  IncrementWrapFlags { IncrementAnyWrap = 0, IncrementNUSW = (1 << 0), IncrementNSSW = (1 << 1), IncrementNoWrapMask = (1 << 2) - 1 }
 Similar to SCEV::NoWrapFlags, but with slightly different semantics for FlagNUSW. More...
 
- Public Types inherited from llvm::SCEVPredicate
enum  SCEVPredicateKind { P_Union, P_Equal, P_Wrap }
 

Public Member Functions

 SCEVWrapPredicate (const FoldingSetNodeIDRef ID, const SCEVAddRecExpr *AR, IncrementWrapFlags Flags)
 
IncrementWrapFlags getFlags () const
 Returns the set assumed no overflow flags. More...
 
const SCEVgetExpr () const override
 Implementation of the SCEVPredicate interface. More...
 
bool implies (const SCEVPredicate *N) const override
 Returns true if this predicate implies N. More...
 
void print (raw_ostream &OS, unsigned Depth=0) const override
 Prints a textual representation of this predicate with an indentation of Depth. More...
 
bool isAlwaysTrue () const override
 Returns true if the predicate is always true. More...
 
- Public Member Functions inherited from llvm::SCEVPredicate
 SCEVPredicate (const FoldingSetNodeIDRef ID, SCEVPredicateKind Kind)
 SCEV predicates. More...
 
SCEVPredicateKind getKind () const
 
virtual unsigned getComplexity () const
 Returns the estimated complexity of this predicate. More...
 
- Public Member Functions inherited from llvm::FoldingSetBase::Node
 Node ()=default
 
void * getNextInBucket () const
 
void SetNextInBucket (void *N)
 

Static Public Member Functions

static LLVM_NODISCARD SCEVWrapPredicate::IncrementWrapFlags clearFlags (SCEVWrapPredicate::IncrementWrapFlags Flags, SCEVWrapPredicate::IncrementWrapFlags OffFlags)
 Convenient IncrementWrapFlags manipulation methods. More...
 
static LLVM_NODISCARD SCEVWrapPredicate::IncrementWrapFlags maskFlags (SCEVWrapPredicate::IncrementWrapFlags Flags, int Mask)
 
static LLVM_NODISCARD SCEVWrapPredicate::IncrementWrapFlags setFlags (SCEVWrapPredicate::IncrementWrapFlags Flags, SCEVWrapPredicate::IncrementWrapFlags OnFlags)
 
static LLVM_NODISCARD SCEVWrapPredicate::IncrementWrapFlags getImpliedFlags (const SCEVAddRecExpr *AR, ScalarEvolution &SE)
 Returns the set of SCEVWrapPredicate no wrap flags implied by a SCEVAddRecExpr. More...
 
static bool classof (const SCEVPredicate *P)
 Methods for support type inquiry through isa, cast, and dyn_cast: More...
 

Additional Inherited Members

- Protected Member Functions inherited from llvm::SCEVPredicate
 ~SCEVPredicate ()=default
 
 SCEVPredicate (const SCEVPredicate &)=default
 
SCEVPredicateoperator= (const SCEVPredicate &)=default
 
- Protected Attributes inherited from llvm::SCEVPredicate
SCEVPredicateKind Kind
 

Detailed Description

This class represents an assumption made on an AddRec expression.

Given an affine AddRec expression {a,+,b}, we assume that it has the nssw or nusw flags (defined below) in the first X iterations of the loop, where X is a SCEV expression returned by getPredicatedBackedgeTakenCount).

Note that this does not imply that X is equal to the backedge taken count. This means that if we have a nusw predicate for i32 {0,+,1} with a predicated backedge taken count of X, we only guarantee that {0,+,1} has nusw in the first X iterations. {0,+,1} may still wrap in the loop if we have more than X iterations.

Definition at line 286 of file ScalarEvolution.h.

Member Enumeration Documentation

◆ IncrementWrapFlags

Similar to SCEV::NoWrapFlags, but with slightly different semantics for FlagNUSW.

The increment is considered to be signed, and a + b (where b is the increment) is considered to wrap if: zext(a + b) != zext(a) + sext(b)

If Signed is a function that takes an n-bit tuple and maps to the integer domain as the tuples value interpreted as twos complement, and Unsigned a function that takes an n-bit tuple and maps to the integer domain as as the base two value of input tuple, then a + b has IncrementNUSW iff:

0 <= Unsigned(a) + Signed(b) < 2^n

The IncrementNSSW flag has identical semantics with SCEV::FlagNSW.

Note that the IncrementNUSW flag is not commutative: if base + inc has IncrementNUSW, then inc + base doesn't neccessarily have this property. The reason for this is that this is used for sign/zero extending affine AddRec SCEV expressions when a SCEVWrapPredicate is assumed. A {base,+,inc} expression is already non-commutative with regards to base and inc, since it is interpreted as: (((base + inc) + inc) + inc) ...

Enumerator
IncrementAnyWrap 
IncrementNUSW 
IncrementNSSW 
IncrementNoWrapMask 

Definition at line 310 of file ScalarEvolution.h.

Constructor & Destructor Documentation

◆ SCEVWrapPredicate()

SCEVWrapPredicate::SCEVWrapPredicate ( const FoldingSetNodeIDRef  ID,
const SCEVAddRecExpr AR,
IncrementWrapFlags  Flags 
)
explicit

Definition at line 12174 of file ScalarEvolution.cpp.

Member Function Documentation

◆ classof()

static bool llvm::SCEVWrapPredicate::classof ( const SCEVPredicate P)
inlinestatic

Methods for support type inquiry through isa, cast, and dyn_cast:

Definition at line 370 of file ScalarEvolution.h.

References llvm::SCEVPredicate::getKind().

◆ clearFlags()

static LLVM_NODISCARD SCEVWrapPredicate::IncrementWrapFlags llvm::SCEVWrapPredicate::clearFlags ( SCEVWrapPredicate::IncrementWrapFlags  Flags,
SCEVWrapPredicate::IncrementWrapFlags  OffFlags 
)
inlinestatic

Convenient IncrementWrapFlags manipulation methods.

Definition at line 320 of file ScalarEvolution.h.

References assert(), and LLVM_NODISCARD.

Referenced by llvm::PredicatedScalarEvolution::hasNoOverflow(), isAlwaysTrue(), and llvm::PredicatedScalarEvolution::setNoOverflow().

◆ getExpr()

const SCEV * SCEVWrapPredicate::getExpr ( ) const
overridevirtual

Implementation of the SCEVPredicate interface.

Implements llvm::SCEVPredicate.

Definition at line 12179 of file ScalarEvolution.cpp.

Referenced by llvm::SCEVExpander::expandWrapPredicate(), and print().

◆ getFlags()

IncrementWrapFlags llvm::SCEVWrapPredicate::getFlags ( ) const
inline

Returns the set assumed no overflow flags.

Definition at line 361 of file ScalarEvolution.h.

References llvm::Depth, llvm::HexagonMCInstrInfo::getExpr(), N, and llvm::SCEV::print().

Referenced by llvm::SCEVExpander::expandWrapPredicate(), and print().

◆ getImpliedFlags()

SCEVWrapPredicate::IncrementWrapFlags SCEVWrapPredicate::getImpliedFlags ( const SCEVAddRecExpr AR,
ScalarEvolution SE 
)
static

◆ implies()

bool SCEVWrapPredicate::implies ( const SCEVPredicate N) const
overridevirtual

Returns true if this predicate implies N.

Implements llvm::SCEVPredicate.

Definition at line 12181 of file ScalarEvolution.cpp.

References llvm::dyn_cast(), N, and setFlags().

◆ isAlwaysTrue()

bool SCEVWrapPredicate::isAlwaysTrue ( ) const
overridevirtual

Returns true if the predicate is always true.

This means that no assumptions were made and nothing needs to be checked at run-time.

Implements llvm::SCEVPredicate.

Definition at line 12187 of file ScalarEvolution.cpp.

References clearFlags(), llvm::SCEV::FlagNSW, llvm::SCEVNAryExpr::getNoWrapFlags(), IncrementAnyWrap, IncrementNSSW, and llvm::ScalarEvolution::setFlags().

◆ maskFlags()

static LLVM_NODISCARD SCEVWrapPredicate::IncrementWrapFlags llvm::SCEVWrapPredicate::maskFlags ( SCEVWrapPredicate::IncrementWrapFlags  Flags,
int  Mask 
)
inlinestatic

Definition at line 329 of file ScalarEvolution.h.

References assert(), LLVM_NODISCARD, and llvm::BitmaskEnumDetail::Mask().

◆ print()

void SCEVWrapPredicate::print ( raw_ostream OS,
unsigned  Depth = 0 
) const
overridevirtual

Prints a textual representation of this predicate with an indentation of Depth.

Implements llvm::SCEVPredicate.

Definition at line 12197 of file ScalarEvolution.cpp.

References getExpr(), getFlags(), IncrementNSSW, IncrementNUSW, and llvm::raw_ostream::indent().

◆ setFlags()

static LLVM_NODISCARD SCEVWrapPredicate::IncrementWrapFlags llvm::SCEVWrapPredicate::setFlags ( SCEVWrapPredicate::IncrementWrapFlags  Flags,
SCEVWrapPredicate::IncrementWrapFlags  OnFlags 
)
inlinestatic

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