LLVM  14.0.0git
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
llvm::CmpInst Class Reference

This class is the base class for the comparison instructions. More...

#include "llvm/IR/InstrTypes.h"

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

Public Types

enum  Predicate : unsigned {
  FCMP_FALSE = 0, FCMP_OEQ = 1, FCMP_OGT = 2, FCMP_OGE = 3,
  FCMP_OLT = 4, FCMP_OLE = 5, FCMP_ONE = 6, FCMP_ORD = 7,
  FCMP_UNO = 8, FCMP_UEQ = 9, FCMP_UGT = 10, FCMP_UGE = 11,
  FCMP_ULT = 12, FCMP_ULE = 13, FCMP_UNE = 14, FCMP_TRUE = 15,
  FIRST_FCMP_PREDICATE = FCMP_FALSE, LAST_FCMP_PREDICATE = FCMP_TRUE, BAD_FCMP_PREDICATE = FCMP_TRUE + 1, ICMP_EQ = 32,
  ICMP_NE = 33, ICMP_UGT = 34, ICMP_UGE = 35, ICMP_ULT = 36,
  ICMP_ULE = 37, ICMP_SGT = 38, ICMP_SGE = 39, ICMP_SLT = 40,
  ICMP_SLE = 41, FIRST_ICMP_PREDICATE = ICMP_EQ, LAST_ICMP_PREDICATE = ICMP_SLE, BAD_ICMP_PREDICATE = ICMP_SLE + 1
}
 This enumeration lists the possible predicates for CmpInst subclasses. More...
 
using PredicateField = Bitfield::Element< Predicate, 0, 6, LAST_ICMP_PREDICATE >
 
- Public Types inherited from llvm::Instruction
enum  OperationEquivalenceFlags { CompareIgnoringAlignment = 1<<0, CompareUsingScalarTypes = 1<<1 }
 When checking for operation equivalence (using isSameOperationAs) it is sometimes useful to ignore certain attributes. More...
 
enum  TermOps
 
enum  UnaryOps
 
enum  BinaryOps
 
enum  MemoryOps
 
enum  CastOps
 
enum  FuncletPadOps
 
enum  OtherOps
 
- Public Types inherited from llvm::User
using op_iterator = Use *
 
using const_op_iterator = const Use *
 
using op_range = iterator_range< op_iterator >
 
using const_op_range = iterator_range< const_op_iterator >
 
- Public Types inherited from llvm::Value
enum  ValueTy
 Concrete subclass of this. More...
 
using use_iterator = use_iterator_impl< Use >
 
using const_use_iterator = use_iterator_impl< const Use >
 
using user_iterator = user_iterator_impl< User >
 
using const_user_iterator = user_iterator_impl< const User >
 

Public Member Functions

void * operator new (size_t S)
 
void operator delete (void *Ptr)
 
OtherOps getOpcode () const
 Get the opcode casted to the right type. More...
 
Predicate getPredicate () const
 Return the predicate for this instruction. More...
 
void setPredicate (Predicate P)
 Set the predicate for this instruction to the specified value. More...
 
bool isFPPredicate () const
 
bool isIntPredicate () const
 
Predicate getInversePredicate () const
 For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc. More...
 
Predicate getSwappedPredicate () const
 For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc. More...
 
bool isStrictPredicate () const
 
bool isNonStrictPredicate () const
 
Predicate getStrictPredicate () const
 For example, SGE -> SGT, SLE -> SLT, ULE -> ULT, UGE -> UGT. More...
 
Predicate getNonStrictPredicate () const
 For example, SGT -> SGE, SLT -> SLE, ULT -> ULE, UGT -> UGE. More...
 
Predicate getFlippedStrictnessPredicate () const
 For predicate of kind "is X or equal to 0" returns the predicate "is X". More...
 
 DECLARE_TRANSPARENT_OPERAND_ACCESSORS (Value)
 Provide more efficient getOperand methods. More...
 
void swapOperands ()
 This is just a convenience that dispatches to the subclasses. More...
 
bool isCommutative () const
 This is just a convenience that dispatches to the subclasses. More...
 
bool isEquality () const
 Determine if this is an equals/not equals predicate. More...
 
bool isRelational () const
 Return true if the predicate is relational (not EQ or NE). More...
 
bool isSigned () const
 
bool isUnsigned () const
 
Predicate getSignedPredicate ()
 For example, ULT->SLT, ULE->SLE, UGT->SGT, UGE->SGE, SLT->Failed assert. More...
 
Predicate getUnsignedPredicate ()
 For example, SLT->ULT, SLE->ULE, SGT->UGT, SGE->UGE, ULT->Failed assert. More...
 
Predicate getFlippedSignednessPredicate ()
 For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->Failed assert. More...
 
bool isTrueWhenEqual () const
 This is just a convenience. More...
 
bool isFalseWhenEqual () const
 This is just a convenience. More...
 
- Public Member Functions inherited from llvm::Instruction
 Instruction (const Instruction &)=delete
 
Instructionoperator= (const Instruction &)=delete
 
Instructionuser_back ()
 Specialize the methods defined in Value, as we know that an instruction can only be used by other instructions. More...
 
const Instructionuser_back () const
 
const BasicBlockgetParent () const
 
BasicBlockgetParent ()
 
const ModulegetModule () const
 Return the module owning the function this instruction belongs to or nullptr it the function does not have a module. More...
 
ModulegetModule ()
 
const FunctiongetFunction () const
 Return the function this instruction belongs to. More...
 
FunctiongetFunction ()
 
void removeFromParent ()
 This method unlinks 'this' from the containing basic block, but does not delete it. More...
 
SymbolTableList< Instruction >::iterator eraseFromParent ()
 This method unlinks 'this' from the containing basic block and deletes it. More...
 
void insertBefore (Instruction *InsertPos)
 Insert an unlinked instruction into a basic block immediately before the specified instruction. More...
 
void insertAfter (Instruction *InsertPos)
 Insert an unlinked instruction into a basic block immediately after the specified instruction. More...
 
void moveBefore (Instruction *MovePos)
 Unlink this instruction from its current basic block and insert it into the basic block that MovePos lives in, right before MovePos. More...
 
void moveBefore (BasicBlock &BB, SymbolTableList< Instruction >::iterator I)
 Unlink this instruction and insert into BB before I. More...
 
void moveAfter (Instruction *MovePos)
 Unlink this instruction from its current basic block and insert it into the basic block that MovePos lives in, right after MovePos. More...
 
bool comesBefore (const Instruction *Other) const
 Given an instruction Other in the same basic block as this instruction, return true if this instruction comes before Other. More...
 
unsigned getOpcode () const
 Returns a member of one of the enums like Instruction::Add. More...
 
const char * getOpcodeName () const
 
bool isTerminator () const
 
bool isUnaryOp () const
 
bool isBinaryOp () const
 
bool isIntDivRem () const
 
bool isShift () const
 
bool isCast () const
 
bool isFuncletPad () const
 
bool isExceptionalTerminator () const
 
bool isOnlyUserOfAnyOperand ()
 It checks if this instruction is the only user of at least one of its operands. More...
 
bool isIndirectTerminator () const
 
bool isLogicalShift () const
 Return true if this is a logical shift left or a logical shift right. More...
 
bool isArithmeticShift () const
 Return true if this is an arithmetic shift right. More...
 
bool isBitwiseLogicOp () const
 Return true if this is and/or/xor. More...
 
bool hasMetadata () const
 Return true if this instruction has any metadata attached to it. More...
 
bool hasMetadataOtherThanDebugLoc () const
 Return true if this instruction has metadata attached to it other than a debug location. More...
 
bool hasMetadata (unsigned KindID) const
 Return true if this instruction has the given type of metadata attached. More...
 
bool hasMetadata (StringRef Kind) const
 Return true if this instruction has the given type of metadata attached. More...
 
MDNodegetMetadata (unsigned KindID) const
 Get the metadata of given kind attached to this Instruction. More...
 
MDNodegetMetadata (StringRef Kind) const
 Get the metadata of given kind attached to this Instruction. More...
 
void getAllMetadata (SmallVectorImpl< std::pair< unsigned, MDNode * >> &MDs) const
 Get all metadata attached to this Instruction. More...
 
void getAllMetadataOtherThanDebugLoc (SmallVectorImpl< std::pair< unsigned, MDNode * >> &MDs) const
 This does the same thing as getAllMetadata, except that it filters out the debug location. More...
 
AAMDNodes getAAMetadata () const
 Returns the AA metadata for this instruction. More...
 
void setMetadata (unsigned KindID, MDNode *Node)
 Set the metadata of the specified kind to the specified node. More...
 
void setMetadata (StringRef Kind, MDNode *Node)
 
void copyMetadata (const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
 Copy metadata from SrcInst to this instruction. More...
 
void swapProfMetadata ()
 If the instruction has "branch_weights" MD_prof metadata and the MDNode has three operands (including name string), swap the order of the metadata. More...
 
void addAnnotationMetadata (StringRef Annotation)
 Adds an !annotation metadata node with Annotation to this instruction. More...
 
void setAAMetadata (const AAMDNodes &N)
 Sets the metadata on this instruction from the AAMDNodes structure. More...
 
bool extractProfMetadata (uint64_t &TrueVal, uint64_t &FalseVal) const
 Retrieve the raw weight values of a conditional branch or select. More...
 
bool extractProfTotalWeight (uint64_t &TotalVal) const
 Retrieve total raw weight values of a branch. More...
 
void setDebugLoc (DebugLoc Loc)
 Set the debug location information for this instruction. More...
 
const DebugLocgetDebugLoc () const
 Return the debug location for this node as a DebugLoc. More...
 
void setHasNoUnsignedWrap (bool b=true)
 Set or clear the nuw flag on this instruction, which must be an operator which supports this flag. More...
 
void setHasNoSignedWrap (bool b=true)
 Set or clear the nsw flag on this instruction, which must be an operator which supports this flag. More...
 
void setIsExact (bool b=true)
 Set or clear the exact flag on this instruction, which must be an operator which supports this flag. More...
 
bool hasNoUnsignedWrap () const
 Determine whether the no unsigned wrap flag is set. More...
 
bool hasNoSignedWrap () const
 Determine whether the no signed wrap flag is set. More...
 
void dropPoisonGeneratingFlags ()
 Drops flags that may cause this instruction to evaluate to poison despite having non-poison inputs. More...
 
void dropUndefImplyingAttrsAndUnknownMetadata (ArrayRef< unsigned > KnownIDs={})
 This function drops non-debug unknown metadata (through dropUnknownNonDebugMetadata). More...
 
bool isExact () const
 Determine whether the exact flag is set. More...
 
void setFast (bool B)
 Set or clear all fast-math-flags on this instruction, which must be an operator which supports this flag. More...
 
void setHasAllowReassoc (bool B)
 Set or clear the reassociation flag on this instruction, which must be an operator which supports this flag. More...
 
void setHasNoNaNs (bool B)
 Set or clear the no-nans flag on this instruction, which must be an operator which supports this flag. More...
 
void setHasNoInfs (bool B)
 Set or clear the no-infs flag on this instruction, which must be an operator which supports this flag. More...
 
void setHasNoSignedZeros (bool B)
 Set or clear the no-signed-zeros flag on this instruction, which must be an operator which supports this flag. More...
 
void setHasAllowReciprocal (bool B)
 Set or clear the allow-reciprocal flag on this instruction, which must be an operator which supports this flag. More...
 
void setHasAllowContract (bool B)
 Set or clear the allow-contract flag on this instruction, which must be an operator which supports this flag. More...
 
void setHasApproxFunc (bool B)
 Set or clear the approximate-math-functions flag on this instruction, which must be an operator which supports this flag. More...
 
void setFastMathFlags (FastMathFlags FMF)
 Convenience function for setting multiple fast-math flags on this instruction, which must be an operator which supports these flags. More...
 
void copyFastMathFlags (FastMathFlags FMF)
 Convenience function for transferring all fast-math flag values to this instruction, which must be an operator which supports these flags. More...
 
bool isFast () const
 Determine whether all fast-math-flags are set. More...
 
bool hasAllowReassoc () const
 Determine whether the allow-reassociation flag is set. More...
 
bool hasNoNaNs () const
 Determine whether the no-NaNs flag is set. More...
 
bool hasNoInfs () const
 Determine whether the no-infs flag is set. More...
 
bool hasNoSignedZeros () const
 Determine whether the no-signed-zeros flag is set. More...
 
bool hasAllowReciprocal () const
 Determine whether the allow-reciprocal flag is set. More...
 
bool hasAllowContract () const
 Determine whether the allow-contract flag is set. More...
 
bool hasApproxFunc () const
 Determine whether the approximate-math-functions flag is set. More...
 
FastMathFlags getFastMathFlags () const
 Convenience function for getting all the fast-math flags, which must be an operator which supports these flags. More...
 
void copyFastMathFlags (const Instruction *I)
 Copy I's fast-math flags. More...
 
void copyIRFlags (const Value *V, bool IncludeWrapFlags=true)
 Convenience method to copy supported exact, fast-math, and (optionally) wrapping flags from V to this instruction. More...
 
void andIRFlags (const Value *V)
 Logical 'and' of any supported wrapping, exact, and fast-math flags of V and this instruction. More...
 
void applyMergedLocation (const DILocation *LocA, const DILocation *LocB)
 Merge 2 debug locations and apply it to the Instruction. More...
 
void updateLocationAfterHoist ()
 Updates the debug location given that the instruction has been hoisted from a block to a predecessor of that block. More...
 
void dropLocation ()
 Drop the instruction's debug location. More...
 
bool isAssociative () const LLVM_READONLY
 Return true if the instruction is associative: More...
 
bool isCommutative () const LLVM_READONLY
 Return true if the instruction is commutative: More...
 
bool isIdempotent () const
 Return true if the instruction is idempotent: More...
 
bool isNilpotent () const
 Return true if the instruction is nilpotent: More...
 
bool mayWriteToMemory () const
 Return true if this instruction may modify memory. More...
 
bool mayReadFromMemory () const
 Return true if this instruction may read memory. More...
 
bool mayReadOrWriteMemory () const
 Return true if this instruction may read or write memory. More...
 
bool isAtomic () const
 Return true if this instruction has an AtomicOrdering of unordered or higher. More...
 
bool hasAtomicLoad () const
 Return true if this atomic instruction loads from memory. More...
 
bool hasAtomicStore () const
 Return true if this atomic instruction stores to memory. More...
 
bool isVolatile () const
 Return true if this instruction has a volatile memory access. More...
 
bool mayThrow () const
 Return true if this instruction may throw an exception. More...
 
bool isFenceLike () const
 Return true if this instruction behaves like a memory fence: it can load or store to memory location without being given a memory location. More...
 
bool mayHaveSideEffects () const
 Return true if the instruction may have side effects. More...
 
bool isSafeToRemove () const
 Return true if the instruction can be removed if the result is unused. More...
 
bool willReturn () const
 Return true if the instruction will return (unwinding is considered as a form of returning control flow here). More...
 
bool isEHPad () const
 Return true if the instruction is a variety of EH-block. More...
 
bool isLifetimeStartOrEnd () const
 Return true if the instruction is a llvm.lifetime.start or llvm.lifetime.end marker. More...
 
bool isLaunderOrStripInvariantGroup () const
 Return true if the instruction is a llvm.launder.invariant.group or llvm.strip.invariant.group. More...
 
bool isDebugOrPseudoInst () const
 Return true if the instruction is a DbgInfoIntrinsic or PseudoProbeInst. More...
 
const InstructiongetNextNonDebugInstruction (bool SkipPseudoOp=false) const
 Return a pointer to the next non-debug instruction in the same basic block as 'this', or nullptr if no such instruction exists. More...
 
InstructiongetNextNonDebugInstruction (bool SkipPseudoOp=false)
 
const InstructiongetPrevNonDebugInstruction (bool SkipPseudoOp=false) const
 Return a pointer to the previous non-debug instruction in the same basic block as 'this', or nullptr if no such instruction exists. More...
 
InstructiongetPrevNonDebugInstruction (bool SkipPseudoOp=false)
 
Instructionclone () const
 Create a copy of 'this' instruction that is identical in all ways except the following: More...
 
bool isIdenticalTo (const Instruction *I) const
 Return true if the specified instruction is exactly identical to the current one. More...
 
bool isIdenticalToWhenDefined (const Instruction *I) const
 This is like isIdenticalTo, except that it ignores the SubclassOptionalData flags, which may specify conditions under which the instruction's result is undefined. More...
 
bool isSameOperationAs (const Instruction *I, unsigned flags=0) const
 This function determines if the specified instruction executes the same operation as the current one. More...
 
bool isUsedOutsideOfBlock (const BasicBlock *BB) const
 Return true if there are any uses of this instruction in blocks other than the specified block. More...
 
unsigned getNumSuccessors () const
 Return the number of successors that this instruction has. More...
 
BasicBlockgetSuccessor (unsigned Idx) const
 Return the specified successor. This instruction must be a terminator. More...
 
void setSuccessor (unsigned Idx, BasicBlock *BB)
 Update the specified successor to point at the provided block. More...
 
void replaceSuccessorWith (BasicBlock *OldBB, BasicBlock *NewBB)
 Replace specified successor OldBB to point at the provided block. More...
 
void dropUnknownNonDebugMetadata (ArrayRef< unsigned > KnownIDs)
 Drop all unknown metadata except for debug locations. More...
 
void dropUnknownNonDebugMetadata ()
 
void dropUnknownNonDebugMetadata (unsigned ID1)
 
void dropUnknownNonDebugMetadata (unsigned ID1, unsigned ID2)
 
- Public Member Functions inherited from llvm::User
 User (const User &)=delete
 
void operator delete (void *Usr)
 Free memory allocated for User and Use objects. More...
 
void operator delete (void *Usr, unsigned)
 Placement delete - required by std, called if the ctor throws. More...
 
void operator delete (void *Usr, unsigned, unsigned)
 Placement delete - required by std, called if the ctor throws. More...
 
const UsegetOperandList () const
 
UsegetOperandList ()
 
ValuegetOperand (unsigned i) const
 
void setOperand (unsigned i, Value *Val)
 
const UsegetOperandUse (unsigned i) const
 
UsegetOperandUse (unsigned i)
 
unsigned getNumOperands () const
 
ArrayRef< const uint8_t > getDescriptor () const
 Returns the descriptor co-allocated with this User instance. More...
 
MutableArrayRef< uint8_t > getDescriptor ()
 Returns the descriptor co-allocated with this User instance. More...
 
void setGlobalVariableNumOperands (unsigned NumOps)
 Set the number of operands on a GlobalVariable. More...
 
void setNumHungOffUseOperands (unsigned NumOps)
 Subclasses with hung off uses need to manage the operand count themselves. More...
 
bool isDroppable () const
 A droppable user is a user for which uses can be dropped without affecting correctness and should be dropped rather than preventing a transformation from happening. More...
 
op_iterator op_begin ()
 
const_op_iterator op_begin () const
 
op_iterator op_end ()
 
const_op_iterator op_end () const
 
op_range operands ()
 
const_op_range operands () const
 
value_op_iterator value_op_begin ()
 
value_op_iterator value_op_end ()
 
iterator_range< value_op_iteratoroperand_values ()
 
const_value_op_iterator value_op_begin () const
 
const_value_op_iterator value_op_end () const
 
iterator_range< const_value_op_iteratoroperand_values () const
 
void dropAllReferences ()
 Drop all references to operands. More...
 
void replaceUsesOfWith (Value *From, Value *To)
 Replace uses of one Value with another. More...
 
- Public Member Functions inherited from llvm::Value
 Value (const Value &)=delete
 
Valueoperator= (const Value &)=delete
 
void deleteValue ()
 Delete a pointer to a generic Value. More...
 
void dump () const
 Support for debugging, callable in GDB: V->dump() More...
 
TypegetType () const
 All values are typed, get the type of this value. More...
 
LLVMContextgetContext () const
 All values hold a context through their type. More...
 
bool hasName () const
 
ValueNamegetValueName () const
 
void setValueName (ValueName *VN)
 
StringRef getName () const
 Return a constant reference to the value's name. More...
 
void setName (const Twine &Name)
 Change the name of the value. More...
 
void takeName (Value *V)
 Transfer the name from V to this value. More...
 
std::string getNameOrAsOperand () const
 
void replaceAllUsesWith (Value *V)
 Change all uses of this to point to a new Value. More...
 
void replaceNonMetadataUsesWith (Value *V)
 Change non-metadata uses of this to point to a new Value. More...
 
void replaceUsesWithIf (Value *New, llvm::function_ref< bool(Use &U)> ShouldReplace)
 Go through the uses list for this definition and make each use point to "V" if the callback ShouldReplace returns true for the given Use. More...
 
void replaceUsesOutsideBlock (Value *V, BasicBlock *BB)
 replaceUsesOutsideBlock - Go through the uses list for this definition and make each use point to "V" instead of "this" when the use is outside the block. More...
 
void assertModuleIsMaterializedImpl () const
 
void assertModuleIsMaterialized () const
 
bool use_empty () const
 
bool materialized_use_empty () const
 
use_iterator materialized_use_begin ()
 
const_use_iterator materialized_use_begin () const
 
use_iterator use_begin ()
 
const_use_iterator use_begin () const
 
use_iterator use_end ()
 
const_use_iterator use_end () const
 
iterator_range< use_iteratormaterialized_uses ()
 
iterator_range< const_use_iteratormaterialized_uses () const
 
iterator_range< use_iteratoruses ()
 
iterator_range< const_use_iteratoruses () const
 
bool user_empty () const
 
user_iterator materialized_user_begin ()
 
const_user_iterator materialized_user_begin () const
 
user_iterator user_begin ()
 
const_user_iterator user_begin () const
 
user_iterator user_end ()
 
const_user_iterator user_end () const
 
Useruser_back ()
 
const Useruser_back () const
 
iterator_range< user_iteratormaterialized_users ()
 
iterator_range< const_user_iteratormaterialized_users () const
 
iterator_range< user_iteratorusers ()
 
iterator_range< const_user_iteratorusers () const
 
bool hasOneUse () const
 Return true if there is exactly one use of this value. More...
 
bool hasNUses (unsigned N) const
 Return true if this Value has exactly N uses. More...
 
bool hasNUsesOrMore (unsigned N) const
 Return true if this value has N uses or more. More...
 
bool hasOneUser () const
 Return true if there is exactly one user of this value. More...
 
UsegetSingleUndroppableUse ()
 Return true if there is exactly one use of this value that cannot be dropped. More...
 
const UsegetSingleUndroppableUse () const
 
bool hasNUndroppableUses (unsigned N) const
 Return true if there this value. More...
 
bool hasNUndroppableUsesOrMore (unsigned N) const
 Return true if this value has N uses or more. More...
 
void dropDroppableUses (llvm::function_ref< bool(const Use *)> ShouldDrop=[](const Use *) { return true;})
 Remove every uses that can safely be removed. More...
 
void dropDroppableUsesIn (User &Usr)
 Remove every use of this value in User that can safely be removed. More...
 
bool isUsedInBasicBlock (const BasicBlock *BB) const
 Check if this value is used in the specified basic block. More...
 
unsigned getNumUses () const
 This method computes the number of uses of this Value. More...
 
void addUse (Use &U)
 This method should only be used by the Use class. More...
 
unsigned getValueID () const
 Return an ID for the concrete type of this object. More...
 
unsigned getRawSubclassOptionalData () const
 Return the raw optional flags value contained in this value. More...
 
void clearSubclassOptionalData ()
 Clear the optional flags contained in this value. More...
 
bool hasSameSubclassOptionalData (const Value *V) const
 Check the optional flags for equality. More...
 
bool hasValueHandle () const
 Return true if there is a value handle associated with this value. More...
 
bool isUsedByMetadata () const
 Return true if there is metadata referencing this value. More...
 
bool isTransitiveUsedByMetadataOnly () const
 
bool isSwiftError () const
 Return true if this value is a swifterror value. More...
 
const ValuestripPointerCasts () const
 Strip off pointer casts, all-zero GEPs and address space casts. More...
 
ValuestripPointerCasts ()
 
const ValuestripPointerCastsAndAliases () const
 Strip off pointer casts, all-zero GEPs, address space casts, and aliases. More...
 
ValuestripPointerCastsAndAliases ()
 
const ValuestripPointerCastsSameRepresentation () const
 Strip off pointer casts, all-zero GEPs and address space casts but ensures the representation of the result stays the same. More...
 
ValuestripPointerCastsSameRepresentation ()
 
const ValuestripPointerCastsForAliasAnalysis () const
 Strip off pointer casts, all-zero GEPs, single-argument phi nodes and invariant group info. More...
 
ValuestripPointerCastsForAliasAnalysis ()
 
const ValuestripInBoundsConstantOffsets () const
 Strip off pointer casts and all-constant inbounds GEPs. More...
 
ValuestripInBoundsConstantOffsets ()
 
const ValuestripAndAccumulateConstantOffsets (const DataLayout &DL, APInt &Offset, bool AllowNonInbounds, function_ref< bool(Value &Value, APInt &Offset)> ExternalAnalysis=nullptr) const
 Accumulate the constant offset this value has compared to a base pointer. More...
 
ValuestripAndAccumulateConstantOffsets (const DataLayout &DL, APInt &Offset, bool AllowNonInbounds)
 
const ValuestripAndAccumulateInBoundsConstantOffsets (const DataLayout &DL, APInt &Offset) const
 This is a wrapper around stripAndAccumulateConstantOffsets with the in-bounds requirement set to false. More...
 
ValuestripAndAccumulateInBoundsConstantOffsets (const DataLayout &DL, APInt &Offset)
 
const ValuestripInBoundsOffsets (function_ref< void(const Value *)> Func=[](const Value *) {}) const
 Strip off pointer casts and inbounds GEPs. More...
 
ValuestripInBoundsOffsets (function_ref< void(const Value *)> Func=[](const Value *) {})
 
bool canBeFreed () const
 Return true if the memory object referred to by V can by freed in the scope for which the SSA value defining the allocation is statically defined. More...
 
uint64_t getPointerDereferenceableBytes (const DataLayout &DL, bool &CanBeNull, bool &CanBeFreed) const
 Returns the number of bytes known to be dereferenceable for the pointer value. More...
 
Align getPointerAlignment (const DataLayout &DL) const
 Returns an alignment of the pointer value. More...
 
const ValueDoPHITranslation (const BasicBlock *CurBB, const BasicBlock *PredBB) const
 Translate PHI node to its predecessor from the given basic block. More...
 
ValueDoPHITranslation (const BasicBlock *CurBB, const BasicBlock *PredBB)
 
void mutateType (Type *Ty)
 Mutate the type of this Value to be of the specified type. More...
 
template<class Compare >
void sortUseList (Compare Cmp)
 Sort the use-list. More...
 
void reverseUseList ()
 Reverse the use-list. More...
 
void print (raw_ostream &O, bool IsForDebug=false) const
 Implement operator<< on Value. More...
 
void print (raw_ostream &O, ModuleSlotTracker &MST, bool IsForDebug=false) const
 
void printAsOperand (raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
 Print the name of this Value out to the specified raw_ostream. More...
 
void printAsOperand (raw_ostream &O, bool PrintType, ModuleSlotTracker &MST) const
 
- Public Member Functions inherited from llvm::ilist_node_with_parent< Instruction, BasicBlock >
InstructiongetPrevNode ()
 
const InstructiongetPrevNode () const
 Get the previous node, or nullptr for the list head. More...
 
InstructiongetNextNode ()
 Get the next node, or nullptr for the list tail. More...
 
const InstructiongetNextNode () const
 Get the next node, or nullptr for the list tail. More...
 
- Public Member Functions inherited from llvm::ilist_node_impl< ilist_detail::compute_node_options< Instruction, Options... >::type >
self_iterator getIterator ()
 
const_self_iterator getIterator () const
 
reverse_self_iterator getReverseIterator ()
 
const_reverse_self_iterator getReverseIterator () const
 
bool isSentinel () const
 Check whether this is the sentinel node. More...
 

Static Public Member Functions

static CmpInstCreate (OtherOps Op, Predicate predicate, Value *S1, Value *S2, const Twine &Name="", Instruction *InsertBefore=nullptr)
 Construct a compare instruction, given the opcode, the predicate and the two operands. More...
 
static CmpInstCreate (OtherOps Op, Predicate predicate, Value *S1, Value *S2, const Twine &Name, BasicBlock *InsertAtEnd)
 Construct a compare instruction, given the opcode, the predicate and the two operands. More...
 
static bool isFPPredicate (Predicate P)
 
static bool isIntPredicate (Predicate P)
 
static StringRef getPredicateName (Predicate P)
 
static Predicate getInversePredicate (Predicate pred)
 For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc. More...
 
static Predicate getSwappedPredicate (Predicate pred)
 This is a static version that you can use without an instruction available. More...
 
static bool isStrictPredicate (Predicate predicate)
 This is a static version that you can use without an instruction available. More...
 
static bool isNonStrictPredicate (Predicate predicate)
 This is a static version that you can use without an instruction available. More...
 
static Predicate getStrictPredicate (Predicate pred)
 This is a static version that you can use without an instruction available. More...
 
static Predicate getNonStrictPredicate (Predicate pred)
 This is a static version that you can use without an instruction available. More...
 
static Predicate getFlippedStrictnessPredicate (Predicate pred)
 This is a static version that you can use without an instruction available. More...
 
static bool isEquality (Predicate pred)
 Determine if this is an equals/not equals predicate. More...
 
static bool isRelational (Predicate P)
 Return true if the predicate is relational (not EQ or NE). More...
 
static Predicate getSignedPredicate (Predicate pred)
 For example, ULT->SLT, ULE->SLE, UGT->SGT, UGE->SGE, SLT->Failed assert. More...
 
static Predicate getUnsignedPredicate (Predicate pred)
 For example, SLT->ULT, SLE->ULE, SGT->UGT, SGE->UGE, ULT->Failed assert. More...
 
static Predicate getFlippedSignednessPredicate (Predicate pred)
 For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->Failed assert. More...
 
static bool isUnsigned (Predicate predicate)
 
static bool isSigned (Predicate predicate)
 
static bool isOrdered (Predicate predicate)
 Determine if the predicate is an ordered operation. More...
 
static bool isUnordered (Predicate predicate)
 Determine if the predicate is an unordered operation. More...
 
static bool isTrueWhenEqual (Predicate predicate)
 Determine if the predicate is true when comparing a value with itself. More...
 
static bool isFalseWhenEqual (Predicate predicate)
 Determine if the predicate is false when comparing a value with itself. More...
 
static bool isImpliedTrueByMatchingCmp (Predicate Pred1, Predicate Pred2)
 Determine if Pred1 implies Pred2 is true when two compares have matching operands. More...
 
static bool isImpliedFalseByMatchingCmp (Predicate Pred1, Predicate Pred2)
 Determine if Pred1 implies Pred2 is false when two compares have matching operands. More...
 
static bool classof (const Instruction *I)
 Methods for support type inquiry through isa, cast, and dyn_cast: More...
 
static bool classof (const Value *V)
 
static TypemakeCmpResultType (Type *opnd_type)
 Create a result type for fcmp/icmp. More...
 
- Static Public Member Functions inherited from llvm::Instruction
static const char * getOpcodeName (unsigned OpCode)
 
static bool isTerminator (unsigned OpCode)
 
static bool isUnaryOp (unsigned Opcode)
 
static bool isBinaryOp (unsigned Opcode)
 
static bool isIntDivRem (unsigned Opcode)
 
static bool isShift (unsigned Opcode)
 Determine if the Opcode is one of the shift instructions. More...
 
static bool isBitwiseLogicOp (unsigned Opcode)
 Determine if the Opcode is and/or/xor. More...
 
static bool isCast (unsigned OpCode)
 Determine if the OpCode is one of the CastInst instructions. More...
 
static bool isFuncletPad (unsigned OpCode)
 Determine if the OpCode is one of the FuncletPadInst instructions. More...
 
static bool isExceptionalTerminator (unsigned OpCode)
 Returns true if the OpCode is a terminator related to exception handling. More...
 
static bool isIndirectTerminator (unsigned OpCode)
 Returns true if the OpCode is a terminator with indirect targets. More...
 
static bool isAssociative (unsigned Opcode)
 
static bool isCommutative (unsigned Opcode)
 
static bool isIdempotent (unsigned Opcode)
 
static bool isNilpotent (unsigned Opcode)
 
static bool classof (const Value *V)
 Methods for support type inquiry through isa, cast, and dyn_cast: More...
 
- Static Public Member Functions inherited from llvm::User
static bool classof (const Value *V)
 
- Static Public Member Functions inherited from llvm::Value
static void dropDroppableUse (Use &U)
 Remove the droppable use U. More...
 

Protected Member Functions

 CmpInst (Type *ty, Instruction::OtherOps op, Predicate pred, Value *LHS, Value *RHS, const Twine &Name="", Instruction *InsertBefore=nullptr, Instruction *FlagsSource=nullptr)
 
 CmpInst (Type *ty, Instruction::OtherOps op, Predicate pred, Value *LHS, Value *RHS, const Twine &Name, BasicBlock *InsertAtEnd)
 
- Protected Member Functions inherited from llvm::Instruction
 ~Instruction ()
 
template<typename BitfieldElement >
BitfieldElement::Type getSubclassData () const
 
template<typename BitfieldElement >
void setSubclassData (typename BitfieldElement::Type Value)
 
 Instruction (Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, Instruction *InsertBefore=nullptr)
 
 Instruction (Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, BasicBlock *InsertAtEnd)
 
- Protected Member Functions inherited from llvm::User
void * operator new (size_t Size)
 Allocate a User with an operand pointer co-allocated. More...
 
void * operator new (size_t Size, unsigned Us)
 Allocate a User with the operands co-allocated. More...
 
void * operator new (size_t Size, unsigned Us, unsigned DescBytes)
 Allocate a User with the operands co-allocated. More...
 
 User (Type *ty, unsigned vty, Use *, unsigned NumOps)
 
void allocHungoffUses (unsigned N, bool IsPhi=false)
 Allocate the array of Uses, followed by a pointer (with bottom bit set) to the User. More...
 
void growHungoffUses (unsigned N, bool IsPhi=false)
 Grow the number of hung off uses. More...
 
 ~User ()=default
 
template<int Idx>
UseOp ()
 
template<int Idx>
const UseOp () const
 
- Protected Member Functions inherited from llvm::Value
 Value (Type *Ty, unsigned scid)
 
 ~Value ()
 Value's destructor should be virtual by design, but that would require that Value and all of its subclasses have a vtable that effectively duplicates the information in the value ID. More...
 
void getAllMetadata (SmallVectorImpl< std::pair< unsigned, MDNode * >> &MDs) const
 Appends all metadata attached to this value to MDs, sorting by KindID. More...
 
bool hasMetadata () const
 Return true if this value has any metadata attached to it. More...
 
bool eraseMetadata (unsigned KindID)
 Erase all metadata attachments with the given kind. More...
 
void clearMetadata ()
 Erase all metadata attached to this Value. More...
 
unsigned short getSubclassDataFromValue () const
 
void setValueSubclassData (unsigned short D)
 
MDNodegetMetadata (unsigned KindID) const
 Get the current metadata attachments for the given kind, if any. More...
 
MDNodegetMetadata (StringRef Kind) const
 
void getMetadata (unsigned KindID, SmallVectorImpl< MDNode * > &MDs) const
 Appends all attachments with the given ID to MDs in insertion order. More...
 
void getMetadata (StringRef Kind, SmallVectorImpl< MDNode * > &MDs) const
 
bool hasMetadata (unsigned KindID) const
 Return true if this value has the given type of metadata attached. More...
 
bool hasMetadata (StringRef Kind) const
 
void setMetadata (unsigned KindID, MDNode *Node)
 Set a particular kind of metadata attachment. More...
 
void setMetadata (StringRef Kind, MDNode *Node)
 
void addMetadata (unsigned KindID, MDNode &MD)
 Add a metadata attachment. More...
 
void addMetadata (StringRef Kind, MDNode &MD)
 
- Protected Member Functions inherited from llvm::ilist_node_with_parent< Instruction, BasicBlock >
 ilist_node_with_parent ()=default
 
- Protected Member Functions inherited from llvm::ilist_node_impl< ilist_detail::compute_node_options< Instruction, Options... >::type >
 ilist_node_impl ()=default
 

Additional Inherited Members

- Static Public Attributes inherited from llvm::Value
static constexpr unsigned MaxAlignmentExponent = 30
 The maximum alignment for instructions. More...
 
static constexpr unsigned MaximumAlignment = 1u << MaxAlignmentExponent
 
- Protected Types inherited from llvm::Instruction
using OpaqueField = Bitfield::Element< uint16_t, 0, 15 >
 
template<unsigned Offset>
using AlignmentBitfieldElementT = typename Bitfield::Element< unsigned, Offset, 5, Value::MaxAlignmentExponent >
 
template<unsigned Offset>
using BoolBitfieldElementT = typename Bitfield::Element< bool, Offset, 1 >
 
template<unsigned Offset>
using AtomicOrderingBitfieldElementT = typename Bitfield::Element< AtomicOrdering, Offset, 3, AtomicOrdering::LAST >
 
- Protected Types inherited from llvm::Value
enum  : unsigned { NumUserOperandsBits = 27 }
 The number of operands in the subclass. More...
 
- Protected Types inherited from llvm::ilist_node_impl< ilist_detail::compute_node_options< Instruction, Options... >::type >
using self_iterator = ilist_iterator< ilist_detail::compute_node_options< Instruction, Options... >::type, false, false >
 
using const_self_iterator = ilist_iterator< ilist_detail::compute_node_options< Instruction, Options... >::type, false, true >
 
using reverse_self_iterator = ilist_iterator< ilist_detail::compute_node_options< Instruction, Options... >::type, true, false >
 
using const_reverse_self_iterator = ilist_iterator< ilist_detail::compute_node_options< Instruction, Options... >::type, true, true >
 
- Static Protected Member Functions inherited from llvm::User
template<int Idx, typename U >
static UseOpFrom (const U *that)
 
- Protected Attributes inherited from llvm::Value
unsigned char SubclassOptionalData: 7
 Hold subclass data that can be dropped. More...
 
unsigned NumUserOperands: NumUserOperandsBits
 
unsigned IsUsedByMD: 1
 
unsigned HasName: 1
 
unsigned HasMetadata: 1
 
unsigned HasHungOffUses: 1
 
unsigned HasDescriptor: 1
 

Detailed Description

This class is the base class for the comparison instructions.

Abstract base class of comparison instructions.

Definition at line 710 of file InstrTypes.h.

Member Typedef Documentation

◆ PredicateField

Definition at line 756 of file InstrTypes.h.

Member Enumeration Documentation

◆ Predicate

enum llvm::CmpInst::Predicate : unsigned

This enumeration lists the possible predicates for CmpInst subclasses.

Values in the range 0-31 are reserved for FCmpInst, while values in the range 32-64 are reserved for ICmpInst. This is necessary to ensure the predicate values are not overlapping between the classes.

Some passes (e.g. InstCombine) depend on the bit-wise characteristics of FCMP_* values. Changing the bit patterns requires a potential change to those passes.

Enumerator
FCMP_FALSE 

0 0 0 0 Always false (always folded)

FCMP_OEQ 

0 0 0 1 True if ordered and equal

FCMP_OGT 

0 0 1 0 True if ordered and greater than

FCMP_OGE 

0 0 1 1 True if ordered and greater than or equal

FCMP_OLT 

0 1 0 0 True if ordered and less than

FCMP_OLE 

0 1 0 1 True if ordered and less than or equal

FCMP_ONE 

0 1 1 0 True if ordered and operands are unequal

FCMP_ORD 

0 1 1 1 True if ordered (no nans)

FCMP_UNO 

1 0 0 0 True if unordered: isnan(X) | isnan(Y)

FCMP_UEQ 

1 0 0 1 True if unordered or equal

FCMP_UGT 

1 0 1 0 True if unordered or greater than

FCMP_UGE 

1 0 1 1 True if unordered, greater than, or equal

FCMP_ULT 

1 1 0 0 True if unordered or less than

FCMP_ULE 

1 1 0 1 True if unordered, less than, or equal

FCMP_UNE 

1 1 1 0 True if unordered or not equal

FCMP_TRUE 

1 1 1 1 Always true (always folded)

FIRST_FCMP_PREDICATE 
LAST_FCMP_PREDICATE 
BAD_FCMP_PREDICATE 
ICMP_EQ 

equal

ICMP_NE 

not equal

ICMP_UGT 

unsigned greater than

ICMP_UGE 

unsigned greater or equal

ICMP_ULT 

unsigned less than

ICMP_ULE 

unsigned less or equal

ICMP_SGT 

signed greater than

ICMP_SGE 

signed greater or equal

ICMP_SLT 

signed less than

ICMP_SLE 

signed less or equal

FIRST_ICMP_PREDICATE 
LAST_ICMP_PREDICATE 
BAD_ICMP_PREDICATE 

Definition at line 720 of file InstrTypes.h.

Constructor & Destructor Documentation

◆ CmpInst() [1/2]

CmpInst::CmpInst ( Type ty,
Instruction::OtherOps  op,
Predicate  pred,
Value LHS,
Value RHS,
const Twine Name = "",
Instruction InsertBefore = nullptr,
Instruction FlagsSource = nullptr 
)
protected

◆ CmpInst() [2/2]

CmpInst::CmpInst ( Type ty,
Instruction::OtherOps  op,
Predicate  pred,
Value LHS,
Value RHS,
const Twine Name,
BasicBlock InsertAtEnd 
)
protected

Definition at line 3696 of file Instructions.cpp.

References llvm::Value::setName(), and setPredicate().

Member Function Documentation

◆ classof() [1/2]

static bool llvm::CmpInst::classof ( const Instruction I)
inlinestatic

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

Definition at line 1022 of file InstrTypes.h.

References I.

Referenced by classof().

◆ classof() [2/2]

static bool llvm::CmpInst::classof ( const Value V)
inlinestatic

Definition at line 1026 of file InstrTypes.h.

References classof().

◆ Create() [1/2]

CmpInst * CmpInst::Create ( OtherOps  Op,
Predicate  predicate,
Value S1,
Value S2,
const Twine Name,
BasicBlock InsertAtEnd 
)
static

Construct a compare instruction, given the opcode, the predicate and the two operands.

Also automatically insert this instruction to the end of the BasicBlock specified. Create a CmpInst

Definition at line 3729 of file Instructions.cpp.

References llvm::User::Op().

◆ Create() [2/2]

CmpInst * CmpInst::Create ( OtherOps  Op,
Predicate  predicate,
Value S1,
Value S2,
const Twine Name = "",
Instruction InsertBefore = nullptr 
)
static

◆ DECLARE_TRANSPARENT_OPERAND_ACCESSORS()

llvm::CmpInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS ( Value  )

Provide more efficient getOperand methods.

◆ getFlippedSignednessPredicate() [1/2]

Predicate llvm::CmpInst::getFlippedSignednessPredicate ( )
inline

For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->Failed assert.

Returns
the unsigned version of the signed predicate pred or the signed version of the signed predicate pred.

Definition at line 977 of file InstrTypes.h.

References getPredicate().

◆ getFlippedSignednessPredicate() [2/2]

CmpInst::Predicate CmpInst::getFlippedSignednessPredicate ( Predicate  pred)
static

For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->Failed assert.

Returns
the unsigned version of the signed predicate pred or the signed version of the signed predicate pred.

Definition at line 4020 of file Instructions.cpp.

References assert(), getSignedPredicate(), getUnsignedPredicate(), isRelational(), isSigned(), isUnsigned(), llvm_unreachable, and pred.

◆ getFlippedStrictnessPredicate() [1/2]

Predicate llvm::CmpInst::getFlippedStrictnessPredicate ( ) const
inline

For predicate of kind "is X or equal to 0" returns the predicate "is X".

For predicate of kind "is X" returns the predicate "is X or equal to 0". does not support other kind of predicates.

Returns
the predicate that does not contains is equal to zero if it had and vice versa. Return the flipped strictness of predicate

Definition at line 902 of file InstrTypes.h.

References getPredicate().

Referenced by llvm::InstCombinerImpl::foldICmpBinOp(), llvm::Loop::LoopBounds::getCanonicalPredicate(), and llvm::InstCombiner::getFlippedStrictnessPredicateAndConstant().

◆ getFlippedStrictnessPredicate() [2/2]

CmpInst::Predicate CmpInst::getFlippedStrictnessPredicate ( Predicate  pred)
static

This is a static version that you can use without an instruction available.

Return the flipped strictness of predicate

Definition at line 3959 of file Instructions.cpp.

References assert(), getNonStrictPredicate(), getStrictPredicate(), isNonStrictPredicate(), isRelational(), isStrictPredicate(), llvm_unreachable, and pred.

◆ getInversePredicate() [1/2]

Predicate llvm::CmpInst::getInversePredicate ( ) const
inline

For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.

Returns
the inverse predicate for the instruction's current predicate. Return the inverse of the instruction's predicate.

Definition at line 820 of file InstrTypes.h.

References getPredicate().

Referenced by llvm::CombinerHelper::applyNotCmp(), llvm::InstCombinerImpl::canonicalizeICmpPredicate(), canonicalizeSaturatedAdd(), canonicalizeSaturatedSubtract(), llvm::AArch64GISelUtils::changeVectorFCMPPredToAArch64CC(), llvm::ConstantFoldBinaryInstruction(), countToEliminateCompares(), detectShiftUntilBitTestIdiom(), llvm::ScalarEvolution::evaluatePredicate(), llvm::ScalarEvolution::evaluatePredicateAt(), llvm::InstCombinerImpl::foldICmpShlConstConst(), llvm::InstCombinerImpl::foldICmpShrConstConst(), llvm::InstCombinerImpl::foldICmpUsingKnownBits(), llvm::InstCombinerImpl::foldICmpWithDominatingICmp(), llvm::Loop::LoopBounds::getCanonicalPredicate(), llvm::ValueLatticeElement::getCompare(), llvm::PredicateBase::getConstraint(), getHashValueImpl(), llvm::getICmpCode(), llvm::ScalarEvolution::getLoopInvariantPredicate(), getValueFromICmpCondition(), llvm::GCNTTIImpl::instCombineIntrinsic(), isEqualImpl(), isImpliedCondICmps(), isImpliedFalseByMatchingCmp(), isKnownNonNullFromDominatingCondition(), llvm::ConstantRange::makeSatisfyingICmpRegion(), matchFastFloatClamp(), optimizeLoopExitWithUnknownExitCount(), performBranchToCommonDestFolding(), replaceWithInvariantCond(), simplifyAndOfICmpsWithSameOperands(), simplifyAndOrOfICmpsWithLimitConst(), SimplifyICmpInst(), simplifyICmpWithMinMax(), simplifyOrOfICmpsWithSameOperands(), llvm::InstCombinerImpl::simplifyRangeCheck(), llvm::InstCombinerImpl::visitBranchInst(), llvm::InstCombinerImpl::visitExtractValueInst(), and llvm::InstCombinerImpl::visitXor().

◆ getInversePredicate() [2/2]

CmpInst::Predicate CmpInst::getInversePredicate ( Predicate  pred)
static

For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.

Returns
the inverse predicate for predicate provided in pred. Return the inverse of a given predicate

Definition at line 3760 of file Instructions.cpp.

References FCMP_FALSE, FCMP_OEQ, FCMP_OGE, FCMP_OGT, FCMP_OLE, FCMP_OLT, FCMP_ONE, FCMP_ORD, FCMP_TRUE, FCMP_UEQ, FCMP_UGE, FCMP_UGT, FCMP_ULE, FCMP_ULT, FCMP_UNE, FCMP_UNO, ICMP_EQ, ICMP_NE, ICMP_SGE, ICMP_SGT, ICMP_SLE, ICMP_SLT, ICMP_UGE, ICMP_UGT, ICMP_ULE, ICMP_ULT, llvm_unreachable, and pred.

◆ getNonStrictPredicate() [1/2]

Predicate llvm::CmpInst::getNonStrictPredicate ( ) const
inline

For example, SGT -> SGE, SLT -> SLE, ULT -> ULE, UGT -> UGE.

Returns the non-strict version of strict comparisons.

Definition at line 880 of file InstrTypes.h.

References getPredicate().

Referenced by getFlippedStrictnessPredicate(), llvm::ScalarEvolution::isBasicBlockEntryGuardedByCond(), and processMinMaxIntrinsic().

◆ getNonStrictPredicate() [2/2]

CmpInst::Predicate CmpInst::getNonStrictPredicate ( Predicate  pred)
static

This is a static version that you can use without an instruction available.

Returns
the non-strict version of comparison provided in pred. If pred is not a strict comparison predicate, returns pred. Returns the non-strict version of strict comparisons.

Definition at line 3936 of file Instructions.cpp.

References FCMP_OGE, FCMP_OGT, FCMP_OLE, FCMP_OLT, FCMP_UGE, FCMP_UGT, FCMP_ULE, FCMP_ULT, ICMP_SGE, ICMP_SGT, ICMP_SLE, ICMP_SLT, ICMP_UGE, ICMP_UGT, ICMP_ULE, ICMP_ULT, and pred.

◆ getOpcode()

OtherOps llvm::CmpInst::getOpcode ( ) const
inline

Get the opcode casted to the right type.

Definition at line 791 of file InstrTypes.h.

References llvm::Instruction::getOpcode().

Referenced by llvm::InstCombinerImpl::foldPHIArgOpIntoPHI().

◆ getPredicate()

Predicate llvm::CmpInst::getPredicate ( ) const
inline

Return the predicate for this instruction.

Definition at line 796 of file InstrTypes.h.

Referenced by CanGenerateTest(), canonicalizeSaturatedSubtract(), llvm::ICmpInst::cloneImpl(), llvm::FCmpInst::cloneImpl(), computeUnlikelySuccessors(), llvm::InstCombinerImpl::foldAllocaCmp(), foldAndOrOfEqualityCmpsWithConstants(), llvm::InstCombinerImpl::foldCmpLoadFromIndexedGlobal(), llvm::InstCombinerImpl::foldICmpWithCastOp(), foldICmpWithZextOrSext(), foldIsPowerOf2(), foldLogOpOfMaskedICmps(), llvm::InstCombinerImpl::foldPHIArgOpIntoPHI(), foldSelectICmpAndOr(), foldSelectICmpLshrAshr(), foldSignedTruncationCheck(), getBranchCondString(), GetBranchWeights(), llvm::Loop::LoopBounds::getCanonicalPredicate(), getFlippedSignednessPredicate(), getFlippedStrictnessPredicate(), llvm::getICmpCode(), getInversePredicate(), getNonStrictPredicate(), getSignedPredicate(), getStrictPredicate(), getSwappedPredicate(), getUnsignedPredicate(), getValueFromICmpCondition(), handleBrSelExpect(), AAValueSimplifyFloating::handleCmp(), llvm::FCmpInst::isCommutative(), isEqualImpl(), isEquality(), llvm::FCmpInst::isEquality(), isFalseWhenEqual(), isFPPredicate(), isImpliedCondICmps(), llvm::isImpliedCondition(), isIntPredicate(), isNonStrictPredicate(), isSigned(), isStrictPredicate(), isTrueWhenEqual(), isUnsigned(), llvm::matchDecomposedSelectPattern(), negateICmpIfUsedByBranchOrSelectOnly(), llvm::FastISel::optimizeCmpPredicate(), OptimizeGlobalAddressOfMalloc(), llvm::IRSimilarity::IRInstructionData::predicateForConsistency(), llvm::InstCombinerImpl::replacedSelectWithOperand(), reuseTableCompare(), simplifyAndOrOfFCmps(), simplifyAndOrOfICmpsWithConstants(), simplifyAndOrOfICmpsWithLimitConst(), simplifyAndOrOfICmpsWithZero(), llvm::InstCombinerImpl::simplifyRangeCheck(), llvm::JumpThreadingPass::tryToUnfoldSelect(), and WidenIV::widenWithVariantUse().

◆ getPredicateName()

StringRef CmpInst::getPredicateName ( Predicate  P)
static

◆ getSignedPredicate() [1/2]

Predicate llvm::CmpInst::getSignedPredicate ( )
inline

For example, ULT->SLT, ULE->SLE, UGT->SGT, UGE->SGE, SLT->Failed assert.

Returns
the signed version of the predicate for this instruction (which has to be an unsigned predicate). return the signed version of a predicate

Definition at line 953 of file InstrTypes.h.

References getPredicate().

Referenced by getFlippedSignednessPredicate().

◆ getSignedPredicate() [2/2]

CmpInst::Predicate CmpInst::getSignedPredicate ( Predicate  pred)
static

For example, ULT->SLT, ULE->SLE, UGT->SGT, UGE->SGE, SLT->Failed assert.

Returns
the signed version of the unsigned predicate pred. return the signed version of a predicate

Definition at line 3970 of file Instructions.cpp.

References assert(), ICMP_SGE, ICMP_SGT, ICMP_SLE, ICMP_SLT, ICMP_UGE, ICMP_UGT, ICMP_ULE, ICMP_ULT, isUnsigned(), llvm_unreachable, and pred.

◆ getStrictPredicate() [1/2]

Predicate llvm::CmpInst::getStrictPredicate ( ) const
inline

For example, SGE -> SGT, SLE -> SLT, ULE -> ULT, UGE -> UGT.

Returns the strict version of non-strict comparisons.

Definition at line 867 of file InstrTypes.h.

References getPredicate().

Referenced by getFlippedStrictnessPredicate().

◆ getStrictPredicate() [2/2]

CmpInst::Predicate CmpInst::getStrictPredicate ( Predicate  pred)
static

This is a static version that you can use without an instruction available.

Returns
the strict version of comparison provided in pred. If pred is not a strict comparison predicate, returns pred. Returns the strict version of non-strict comparisons.

Definition at line 3913 of file Instructions.cpp.

References FCMP_OGE, FCMP_OGT, FCMP_OLE, FCMP_OLT, FCMP_UGE, FCMP_UGT, FCMP_ULE, FCMP_ULT, ICMP_SGE, ICMP_SGT, ICMP_SLE, ICMP_SLT, ICMP_UGE, ICMP_UGT, ICMP_ULE, ICMP_ULT, and pred.

◆ getSwappedPredicate() [1/2]

Predicate llvm::CmpInst::getSwappedPredicate ( ) const
inline

For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.

Returns
the predicate that would be the result of exchanging the two operands of the CmpInst instruction without changing the result produced. Return the predicate as if the operands were swapped

Definition at line 836 of file InstrTypes.h.

References getPredicate().

Referenced by llvm::analyzeICmp(), llvm::ScalarEvolution::applyLoopGuards(), applySwapICmpOperands(), canonicalizeSaturatedAdd(), canonicalizeSaturatedSubtract(), llvm::ConstantFoldCompareInstOperands(), llvm::ConstantFoldCompareInstruction(), countToEliminateCompares(), evaluateFCmpRelation(), evaluateICmpRelation(), ExtractEquivalentCondition(), llvm::InstCombinerImpl::foldGEPICmp(), llvm::InstCombinerImpl::foldICmpBinOp(), llvm::InstCombinerImpl::foldICmpDivConstant(), llvm::InstCombinerImpl::foldICmpMulConstant(), foldICmpWithDominatingICmp(), foldICmpXNegX(), llvm::Loop::LoopBounds::getCanonicalPredicate(), llvm::ScalarEvolution::getLoopInvariantExitCondDuringFirstIterations(), llvm::ScalarEvolution::getLoopInvariantPredicate(), llvm::ScalarEvolution::getMonotonicPredicateType(), llvm::LazyValueInfo::getPredicateAt(), getValueFromICmpCondition(), llvm::GCNTTIImpl::instCombineIntrinsic(), isImpliedCondMatchingOperands(), isSameCompare(), matchClamp(), matchMinMaxOfMinMax(), matchSelectPattern(), matchSelectWithOptionalNotCond(), llvm::InstCombinerImpl::matchThreeWayIntCompare(), llvm::IRSimilarity::IRInstructionData::predicateForConsistency(), SimplifyFCmpInst(), SimplifyICmpInst(), llvm::ScalarEvolution::SimplifyICmpOperands(), simplifyICmpWithBinOp(), simplifyICmpWithMinMax(), llvm::InstCombinerImpl::simplifyRangeCheck(), simplifyUnsignedRangeCheck(), llvm::FCmpInst::swapOperands(), ThreadCmpOverPHI(), ThreadCmpOverSelect(), and llvm::InstCombinerImpl::visitICmpInst().

◆ getSwappedPredicate() [2/2]

CmpInst::Predicate CmpInst::getSwappedPredicate ( Predicate  pred)
static

This is a static version that you can use without an instruction available.

Return the predicate as if the operands were swapped.

Definition at line 3851 of file Instructions.cpp.

References FCMP_FALSE, FCMP_OEQ, FCMP_OGE, FCMP_OGT, FCMP_OLE, FCMP_OLT, FCMP_ONE, FCMP_ORD, FCMP_TRUE, FCMP_UEQ, FCMP_UGE, FCMP_UGT, FCMP_ULE, FCMP_ULT, FCMP_UNE, FCMP_UNO, ICMP_EQ, ICMP_NE, ICMP_SGE, ICMP_SGT, ICMP_SLE, ICMP_SLT, ICMP_UGE, ICMP_UGT, ICMP_ULE, ICMP_ULT, llvm_unreachable, and pred.

◆ getUnsignedPredicate() [1/2]

Predicate llvm::CmpInst::getUnsignedPredicate ( )
inline

For example, SLT->ULT, SLE->ULE, SGT->UGT, SGE->UGE, ULT->Failed assert.

Returns
the unsigned version of the predicate for this instruction (which has to be an signed predicate). return the unsigned version of a predicate

Definition at line 965 of file InstrTypes.h.

References getPredicate().

Referenced by getFlippedSignednessPredicate().

◆ getUnsignedPredicate() [2/2]

CmpInst::Predicate CmpInst::getUnsignedPredicate ( Predicate  pred)
static

For example, SLT->ULT, SLE->ULE, SGT->UGT, SGE->UGE, ULT->Failed assert.

Returns
the unsigned version of the signed predicate pred.

Definition at line 3987 of file Instructions.cpp.

References assert(), ICMP_SGE, ICMP_SGT, ICMP_SLE, ICMP_SLT, ICMP_UGE, ICMP_UGT, ICMP_ULE, ICMP_ULT, isSigned(), llvm_unreachable, and pred.

◆ isCommutative()

bool CmpInst::isCommutative ( ) const

This is just a convenience that dispatches to the subclasses.

Determine if this CmpInst is commutative.

Definition at line 3746 of file Instructions.cpp.

◆ isEquality() [1/2]

bool llvm::CmpInst::isEquality ( ) const
inline

Determine if this is an equals/not equals predicate.

Definition at line 924 of file InstrTypes.h.

References getPredicate(), and isEquality().

Referenced by llvm::AArch64GISelUtils::isCMN(), isEquality(), isRelational(), and llvm::CombinerHelper::matchICmpToLHSKnownBits().

◆ isEquality() [2/2]

bool CmpInst::isEquality ( Predicate  pred)
static

Determine if this is an equals/not equals predicate.

This is a static version that you can use without an instruction available.

Definition at line 3752 of file Instructions.cpp.

References llvm::ICmpInst::isEquality(), llvm::FCmpInst::isEquality(), isFPPredicate(), isIntPredicate(), llvm_unreachable, and P.

Referenced by llvm::matchDecomposedSelectPattern(), and llvm::InstCombinerImpl::visitPHINode().

◆ isFalseWhenEqual() [1/2]

bool llvm::CmpInst::isFalseWhenEqual ( ) const
inline

This is just a convenience.

Determine if this is false when both operands are the same.

Definition at line 989 of file InstrTypes.h.

References getPredicate().

Referenced by computePointerICmp(), simplifyAndOfICmpsWithSameOperands(), SimplifyFCmpInst(), and llvm::ScalarEvolution::SimplifyICmpOperands().

◆ isFalseWhenEqual() [2/2]

bool CmpInst::isFalseWhenEqual ( Predicate  predicate)
static

Determine if the predicate is false when comparing a value with itself.

Definition at line 4058 of file Instructions.cpp.

References FCMP_FALSE, FCMP_OGT, FCMP_OLT, FCMP_ONE, ICMP_NE, ICMP_SGT, ICMP_SLT, ICMP_UGT, and ICMP_ULT.

◆ isFPPredicate() [1/2]

bool llvm::CmpInst::isFPPredicate ( ) const
inline

◆ isFPPredicate() [2/2]

static bool llvm::CmpInst::isFPPredicate ( Predicate  P)
inlinestatic

Definition at line 801 of file InstrTypes.h.

References FIRST_FCMP_PREDICATE, LAST_FCMP_PREDICATE, and P.

◆ isImpliedFalseByMatchingCmp()

bool CmpInst::isImpliedFalseByMatchingCmp ( Predicate  Pred1,
Predicate  Pred2 
)
static

Determine if Pred1 implies Pred2 is false when two compares have matching operands.

Definition at line 4091 of file Instructions.cpp.

References getInversePredicate(), and isImpliedTrueByMatchingCmp().

Referenced by isImpliedCondMatchingOperands().

◆ isImpliedTrueByMatchingCmp()

bool CmpInst::isImpliedTrueByMatchingCmp ( Predicate  Pred1,
Predicate  Pred2 
)
static

Determine if Pred1 implies Pred2 is true when two compares have matching operands.

Definition at line 4066 of file Instructions.cpp.

References ICMP_EQ, ICMP_NE, ICMP_SGE, ICMP_SGT, ICMP_SLE, ICMP_SLT, ICMP_UGE, ICMP_UGT, ICMP_ULE, and ICMP_ULT.

Referenced by isImpliedCondMatchingOperands(), isImpliedFalseByMatchingCmp(), simplifyAndOfICmpsWithSameOperands(), and simplifyOrOfICmpsWithSameOperands().

◆ isIntPredicate() [1/2]

bool llvm::CmpInst::isIntPredicate ( ) const
inline

◆ isIntPredicate() [2/2]

static bool llvm::CmpInst::isIntPredicate ( Predicate  P)
inlinestatic

Definition at line 807 of file InstrTypes.h.

References FIRST_ICMP_PREDICATE, LAST_ICMP_PREDICATE, and P.

◆ isNonStrictPredicate() [1/2]

bool llvm::CmpInst::isNonStrictPredicate ( ) const
inline
Returns
true if the comparison predicate is non-strict, false otherwise. Determine if this instruction is using an non-strict comparison predicate.

Definition at line 861 of file InstrTypes.h.

References getPredicate().

Referenced by getFlippedStrictnessPredicate().

◆ isNonStrictPredicate() [2/2]

bool CmpInst::isNonStrictPredicate ( Predicate  predicate)
static

This is a static version that you can use without an instruction available.

Returns
true if the comparison predicate is non-strict, false otherwise.

Definition at line 3881 of file Instructions.cpp.

References FCMP_OGE, FCMP_OLE, FCMP_UGE, FCMP_ULE, ICMP_SGE, ICMP_SLE, ICMP_UGE, ICMP_ULE, and pred.

◆ isOrdered()

bool CmpInst::isOrdered ( Predicate  predicate)
static

Determine if the predicate is an ordered operation.

Definition at line 4032 of file Instructions.cpp.

References FCMP_OEQ, FCMP_OGE, FCMP_OGT, FCMP_OLE, FCMP_OLT, FCMP_ONE, and FCMP_ORD.

Referenced by matchSelectPattern(), and SimplifyFCmpInst().

◆ isRelational() [1/2]

bool llvm::CmpInst::isRelational ( ) const
inline

Return true if the predicate is relational (not EQ or NE).

Definition at line 930 of file InstrTypes.h.

References isEquality().

Referenced by getFlippedSignednessPredicate(), and getFlippedStrictnessPredicate().

◆ isRelational() [2/2]

static bool llvm::CmpInst::isRelational ( Predicate  P)
inlinestatic

Return true if the predicate is relational (not EQ or NE).

Definition at line 927 of file InstrTypes.h.

References isEquality(), and P.

◆ isSigned() [1/2]

bool llvm::CmpInst::isSigned ( ) const
inline

◆ isSigned() [2/2]

bool CmpInst::isSigned ( Predicate  predicate)
static
Returns
true if the predicate is signed, false otherwise. Determine if the predicate is an signed operation.

Definition at line 4012 of file Instructions.cpp.

References ICMP_SGE, ICMP_SGT, ICMP_SLE, and ICMP_SLT.

◆ isStrictPredicate() [1/2]

bool llvm::CmpInst::isStrictPredicate ( ) const
inline
Returns
true if the comparison predicate is strict, false otherwise. Determine if this instruction is using an strict comparison predicate.

Definition at line 852 of file InstrTypes.h.

References getPredicate(), and isStrictPredicate().

Referenced by getFlippedStrictnessPredicate(), and isStrictPredicate().

◆ isStrictPredicate() [2/2]

bool CmpInst::isStrictPredicate ( Predicate  predicate)
static

This is a static version that you can use without an instruction available.

Returns
true if the comparison predicate is strict, false otherwise.

Definition at line 3897 of file Instructions.cpp.

References FCMP_OGT, FCMP_OLT, FCMP_UGT, FCMP_ULT, ICMP_SGT, ICMP_SLT, ICMP_UGT, ICMP_ULT, and pred.

◆ isTrueWhenEqual() [1/2]

bool llvm::CmpInst::isTrueWhenEqual ( ) const
inline

◆ isTrueWhenEqual() [2/2]

bool CmpInst::isTrueWhenEqual ( Predicate  predicate)
static

Determine if the predicate is true when comparing a value with itself.

Definition at line 4050 of file Instructions.cpp.

References FCMP_TRUE, FCMP_UEQ, FCMP_UGE, FCMP_ULE, ICMP_EQ, ICMP_SGE, ICMP_SLE, ICMP_UGE, and ICMP_ULE.

◆ isUnordered()

bool CmpInst::isUnordered ( Predicate  predicate)
static

Determine if the predicate is an unordered operation.

Definition at line 4041 of file Instructions.cpp.

References FCMP_UEQ, FCMP_UGE, FCMP_UGT, FCMP_ULE, FCMP_ULT, FCMP_UNE, and FCMP_UNO.

Referenced by llvm::ConstantFoldCompareInstruction(), and SimplifyFCmpInst().

◆ isUnsigned() [1/2]

bool llvm::CmpInst::isUnsigned ( ) const
inline
Returns
true if the comparison is unsigned, false otherwise. Determine if this instruction is using an unsigned comparison.

Definition at line 940 of file InstrTypes.h.

References getPredicate().

Referenced by canonicalizeSaturatedSubtract(), llvm::InstCombinerImpl::foldICmpBinOp(), foldICmpXNegX(), foldUnsignedUnderflowCheck(), getFlippedSignednessPredicate(), getSignedPredicate(), lookThroughCast(), simplifyICmpWithBinOp(), and simplifyUnsignedRangeCheck().

◆ isUnsigned() [2/2]

bool CmpInst::isUnsigned ( Predicate  predicate)
static
Returns
true if the predicate is unsigned, false otherwise. Determine if the predicate is an unsigned operation.

Definition at line 4004 of file Instructions.cpp.

References ICMP_UGE, ICMP_UGT, ICMP_ULE, and ICMP_ULT.

◆ makeCmpResultType()

static Type* llvm::CmpInst::makeCmpResultType ( Type opnd_type)
inlinestatic

◆ operator delete()

void llvm::CmpInst::operator delete ( void *  Ptr)
inline

Definition at line 771 of file InstrTypes.h.

◆ operator new()

void* llvm::CmpInst::operator new ( size_t  S)
inline

Definition at line 770 of file InstrTypes.h.

References S.

◆ setPredicate()

void llvm::CmpInst::setPredicate ( Predicate  P)
inline

Set the predicate for this instruction to the specified value.

Definition at line 799 of file InstrTypes.h.

References P.

Referenced by CmpInst(), llvm::InstModificationIRStrategy::mutate(), negateICmpIfUsedByBranchOrSelectOnly(), performBranchToCommonDestFolding(), and llvm::FCmpInst::swapOperands().

◆ swapOperands()

void CmpInst::swapOperands ( )

This is just a convenience that dispatches to the subclasses.

Swap the operands and adjust predicate accordingly to retain the same comparison.

Definition at line 3739 of file Instructions.cpp.


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