class CmpInst

Declaration

class CmpInst : public Instruction { /* full declaration omitted */ };

Description

This class is the base class for the comparison instructions. Abstract base class of comparison instructions.

Declared at: llvm/include/llvm/IR/InstrTypes.h:709

Inherits from: Instruction

Member Variables

Inherited from Value:

protected SubclassOptionalData
protected NumUserOperands
protected IsUsedByMD
protected HasName
protected HasMetadata
protected HasHungOffUses
protected HasDescriptor
public static MaxAlignmentExponent = 32
public static MaximumAlignment = 1ULL << MaxAlignmentExponent

Method Overview

Inherited from Instruction:

Inherited from User:

Inherited from Value:

Methods

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:772

Parameters

llvm::Type* ty
Instruction::OtherOps op
llvm::CmpInst::Predicate pred
llvm::Value* LHS
llvm::Value* RHS
const llvm::Twine& Name = ""
llvm::Instruction* InsertBefore = nullptr
llvm::Instruction* FlagsSource = nullptr

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:777

Parameters

llvm::Type* ty
Instruction::OtherOps op
llvm::CmpInst::Predicate pred
llvm::Value* LHS
llvm::Value* RHS
const llvm::Twine& Name
llvm::BasicBlock* InsertAtEnd

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

Description

Construct a compare instruction, given the opcode, the predicate and the two operands. Optionally (if InstBefore is specified) insert the instruction into a BasicBlock right before the specified instruction. The specified Instruction is allowed to be a dereferenced end iterator. Create a CmpInst

Declared at: llvm/include/llvm/IR/InstrTypes.h:791

Parameters

llvm::Instruction::OtherOps Op
llvm::CmpInst::Predicate predicate
llvm::Value* S1
llvm::Value* S2
const llvm::Twine& Name = ""
llvm::Instruction* InsertBefore = nullptr

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

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:800

Parameters

llvm::Instruction::OtherOps Op
llvm::CmpInst::Predicate predicate
llvm::Value* S1
llvm::Value* S2
const llvm::Twine& Name
llvm::BasicBlock* InsertAtEnd

static iota_range<llvm::CmpInst::Predicate>
FCmpPredicates()

Description

Returns the sequence of all FCmp predicates.

Declared at: llvm/include/llvm/IR/InstrTypes.h:758

static iota_range<llvm::CmpInst::Predicate>
ICmpPredicates()

Description

Returns the sequence of all ICmp predicates.

Declared at: llvm/include/llvm/IR/InstrTypes.h:765

static bool classof(const llvm::Value* V)

Declared at: llvm/include/llvm/IR/InstrTypes.h:1039

Parameters

const llvm::Value* V

static bool classof(const llvm::Instruction* I)

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:1035

Parameters

const llvm::Instruction* I

llvm::CmpInst::Predicate
getFlippedSignednessPredicate()

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:990

Returns

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

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

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:985

Parameters

llvm::CmpInst::Predicate pred

Returns

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

llvm::CmpInst::Predicate
getFlippedStrictnessPredicate() const

Description

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.

Declared at: llvm/include/llvm/IR/InstrTypes.h:915

Returns

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

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

Description

This is a static version that you can use without an instruction available. Return the flipped strictness of predicate

Declared at: llvm/include/llvm/IR/InstrTypes.h:907

Parameters

llvm::CmpInst::Predicate pred

llvm::CmpInst::Predicate getInversePredicate()
    const

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:833

Returns

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

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

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:841

Parameters

llvm::CmpInst::Predicate pred

Returns

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

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

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:902

Parameters

llvm::CmpInst::Predicate pred

Returns

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

llvm::CmpInst::Predicate getNonStrictPredicate()
    const

Description

For example, SGT -> SGE, SLT -> SLE, ULT -> ULE, UGT -> UGE. Returns the non-strict version of strict comparisons.

Declared at: llvm/include/llvm/IR/InstrTypes.h:893

llvm::Instruction::OtherOps getOpcode() const

Description

Get the opcode casted to the right type

Declared at: llvm/include/llvm/IR/InstrTypes.h:804

llvm::CmpInst::Predicate getPredicate() const

Description

Return the predicate for this instruction.

Declared at: llvm/include/llvm/IR/InstrTypes.h:809

static llvm::StringRef getPredicateName(
    llvm::CmpInst::Predicate P)

Declared at: llvm/include/llvm/IR/InstrTypes.h:824

Parameters

llvm::CmpInst::Predicate P

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

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:960

Parameters

llvm::CmpInst::Predicate pred

Returns

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

llvm::CmpInst::Predicate getSignedPredicate()

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:966

Returns

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

llvm::CmpInst::Predicate getStrictPredicate()
    const

Description

For example, SGE -> SGT, SLE -> SLT, ULE -> ULT, UGE -> UGT. Returns the strict version of non-strict comparisons.

Declared at: llvm/include/llvm/IR/InstrTypes.h:880

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

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:889

Parameters

llvm::CmpInst::Predicate pred

Returns

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

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

Description

This is a static version that you can use without an instruction available. Return the predicate as if the operands were swapped.

Declared at: llvm/include/llvm/IR/InstrTypes.h:856

Parameters

llvm::CmpInst::Predicate pred

llvm::CmpInst::Predicate getSwappedPredicate()
    const

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:849

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

llvm::CmpInst::Predicate getUnsignedPredicate()

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:978

Returns

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

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

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:972

Parameters

llvm::CmpInst::Predicate pred

Returns

the unsigned version of the signed predicate pred.

bool isCommutative() const

Description

This is just a convenience that dispatches to the subclasses. Determine if this CmpInst is commutative.

Declared at: llvm/include/llvm/IR/InstrTypes.h:929

static bool isEquality(
    llvm::CmpInst::Predicate pred)

Description

Determine if this is an equals/not equals predicate. This is a static version that you can use without an instruction available.

Declared at: llvm/include/llvm/IR/InstrTypes.h:934

Parameters

llvm::CmpInst::Predicate pred

bool isEquality() const

Description

Determine if this is an equals/not equals predicate.

Declared at: llvm/include/llvm/IR/InstrTypes.h:937

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:814

Parameters

llvm::CmpInst::Predicate P

bool isFPPredicate() const

Declared at: llvm/include/llvm/IR/InstrTypes.h:826

static bool isFalseWhenEqual(
    llvm::CmpInst::Predicate predicate)

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:1024

Parameters

llvm::CmpInst::Predicate predicate

bool isFalseWhenEqual() const

Description

This is just a convenience. Determine if this is false when both operands are the same.

Declared at: llvm/include/llvm/IR/InstrTypes.h:1002

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

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:1032

Parameters

llvm::CmpInst::Predicate Pred1
llvm::CmpInst::Predicate Pred2

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

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:1028

Parameters

llvm::CmpInst::Predicate Pred1
llvm::CmpInst::Predicate Pred2

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:820

Parameters

llvm::CmpInst::Predicate P

bool isIntPredicate() const

Declared at: llvm/include/llvm/IR/InstrTypes.h:827

bool isNonStrictPredicate() const

Declared at: llvm/include/llvm/IR/InstrTypes.h:874

Returns

true if the comparison predicate is non-strict, false otherwise. Determine if this instruction is using an non-strict comparison predicate.

static bool isNonStrictPredicate(
    llvm::CmpInst::Predicate predicate)

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:870

Parameters

llvm::CmpInst::Predicate predicate

Returns

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

static bool isOrdered(
    llvm::CmpInst::Predicate predicate)

Description

Determine if the predicate is an ordered operation.

Declared at: llvm/include/llvm/IR/InstrTypes.h:1015

Parameters

llvm::CmpInst::Predicate predicate

bool isRelational() const

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:943

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

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:940

Parameters

llvm::CmpInst::Predicate P

static bool isSigned(
    llvm::CmpInst::Predicate predicate)

Declared at: llvm/include/llvm/IR/InstrTypes.h:1012

Parameters

llvm::CmpInst::Predicate predicate

Returns

true if the predicate is signed, false otherwise. Determine if the predicate is an signed operation.

bool isSigned() const

Declared at: llvm/include/llvm/IR/InstrTypes.h:947

Returns

true if the comparison is signed, false otherwise. Determine if this instruction is using a signed comparison.

bool isStrictPredicate() const

Declared at: llvm/include/llvm/IR/InstrTypes.h:865

Returns

true if the comparison predicate is strict, false otherwise. Determine if this instruction is using an strict comparison predicate.

static bool isStrictPredicate(
    llvm::CmpInst::Predicate predicate)

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:861

Parameters

llvm::CmpInst::Predicate predicate

Returns

true if the comparison predicate is strict, false otherwise.

bool isTrueWhenEqual() const

Description

This is just a convenience. Determine if this is true when both operands are the same.

Declared at: llvm/include/llvm/IR/InstrTypes.h:996

static bool isTrueWhenEqual(
    llvm::CmpInst::Predicate predicate)

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:1021

Parameters

llvm::CmpInst::Predicate predicate

static bool isUnordered(
    llvm::CmpInst::Predicate predicate)

Description

Determine if the predicate is an unordered operation.

Declared at: llvm/include/llvm/IR/InstrTypes.h:1018

Parameters

llvm::CmpInst::Predicate predicate

static bool isUnsigned(
    llvm::CmpInst::Predicate predicate)

Declared at: llvm/include/llvm/IR/InstrTypes.h:1008

Parameters

llvm::CmpInst::Predicate predicate

Returns

true if the predicate is unsigned, false otherwise. Determine if the predicate is an unsigned operation.

bool isUnsigned() const

Declared at: llvm/include/llvm/IR/InstrTypes.h:953

Returns

true if the comparison is unsigned, false otherwise. Determine if this instruction is using an unsigned comparison.

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

Description

Create a result type for fcmp/icmp

Declared at: llvm/include/llvm/IR/InstrTypes.h:1044

Parameters

llvm::Type* opnd_type

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

Description

Set the predicate for this instruction to the specified value.

Declared at: llvm/include/llvm/IR/InstrTypes.h:812

Parameters

llvm::CmpInst::Predicate P

void setValueSubclassData(unsigned short D)

Declared at: llvm/include/llvm/IR/InstrTypes.h:1055

Parameters

unsigned short D

void swapOperands()

Description

This is just a convenience that dispatches to the subclasses. Swap the operands and adjust predicate accordingly to retain the same comparison.

Declared at: llvm/include/llvm/IR/InstrTypes.h:925