LLVM 24.0.0git
llvm::slpvectorizer::CmpSamePredicateHelper Class Reference

Helper class that determines whether a list of integer comparisons can share a single predicate. More...

#include "Transforms/Vectorize/SLPVectorizer/SLPCompatibilityAnalysis.h"

Public Member Functions

bool add (const ICmpInst *CI)
 Intersects the convertible predicate set of CI with the running set.
CmpInst::Predicate getPredicate (const ICmpInst *Preferred) const
 Returns the shared predicate, preferring the predicate of Preferred when the whole list can use it, or BAD_ICMP_PREDICATE when the list cannot share a natively present predicate.

Static Public Member Functions

static CmpInst::Predicate getSharedPredicate (ArrayRef< Value * > VL, const ICmpInst *Preferred)
 Returns the predicate the whole list can share, or BAD_ICMP_PREDICATE when it cannot share a natively present predicate.
static bool canConvertTo (const CmpInst *CI, CmpInst::Predicate Pred)
 Checks if the comparison CI can be expressed with the predicate Pred by adjusting its constant operand.
static ConstantIntgetAdjustedConstant (const CmpInst *CI, CmpInst::Predicate Pred)
 Returns the adjusted constant operand expressing CI with the predicate Pred, or nullptr if not convertible or if CI already uses Pred.

Detailed Description

Helper class that determines whether a list of integer comparisons can share a single predicate.

InstCombine canonicalizes single-element and single-complement range comparisons to eq/ne at the type boundaries (e.g. x <u 1 becomes x == 0); such lanes are interchangeable with the rest of the list by adjusting the compared constant.

Definition at line 141 of file SLPCompatibilityAnalysis.h.

Member Function Documentation

◆ add()

bool llvm::slpvectorizer::CmpSamePredicateHelper::add ( const ICmpInst * CI)

Intersects the convertible predicate set of CI with the running set.

Returns false when the intersection becomes empty.

Definition at line 423 of file SLPCompatibilityAnalysis.cpp.

References C(), llvm::dyn_cast(), llvm::User::getOperand(), and llvm::CmpInst::getPredicate().

Referenced by getSharedPredicate().

◆ canConvertTo()

bool llvm::slpvectorizer::CmpSamePredicateHelper::canConvertTo ( const CmpInst * CI,
CmpInst::Predicate Pred )
static

Checks if the comparison CI can be expressed with the predicate Pred by adjusting its constant operand.

Definition at line 455 of file SLPCompatibilityAnalysis.cpp.

References C(), llvm::dyn_cast(), and llvm::CmpInst::isIntPredicate().

Referenced by getAdjustedConstant(), and llvm::slpvectorizer::getSameOpcode().

◆ getAdjustedConstant()

ConstantInt * llvm::slpvectorizer::CmpSamePredicateHelper::getAdjustedConstant ( const CmpInst * CI,
CmpInst::Predicate Pred )
static

Returns the adjusted constant operand expressing CI with the predicate Pred, or nullptr if not convertible or if CI already uses Pred.

Definition at line 468 of file SLPCompatibilityAnalysis.cpp.

References assert(), C(), canConvertTo(), llvm::cast(), llvm::slpvectorizer::getCmpBoundaryFamily(), and llvm::Value::getContext().

Referenced by llvm::slpvectorizer::convertTo().

◆ getPredicate()

CmpInst::Predicate llvm::slpvectorizer::CmpSamePredicateHelper::getPredicate ( const ICmpInst * Preferred) const

Returns the shared predicate, preferring the predicate of Preferred when the whole list can use it, or BAD_ICMP_PREDICATE when the list cannot share a natively present predicate.

Definition at line 433 of file SLPCompatibilityAnalysis.cpp.

References llvm::CmpInst::BAD_ICMP_PREDICATE, llvm::countr_zero(), llvm::CmpInst::getPredicate(), and llvm::CmpInst::ICMP_EQ.

Referenced by getSharedPredicate().

◆ getSharedPredicate()

CmpInst::Predicate llvm::slpvectorizer::CmpSamePredicateHelper::getSharedPredicate ( ArrayRef< Value * > VL,
const ICmpInst * Preferred )
static

Returns the predicate the whole list can share, or BAD_ICMP_PREDICATE when it cannot share a natively present predicate.

Definition at line 444 of file SLPCompatibilityAnalysis.cpp.

References add(), llvm::all_of(), llvm::CmpInst::BAD_ICMP_PREDICATE, llvm::dyn_cast(), getPredicate(), and llvm::isa().

Referenced by llvm::slpvectorizer::getSameOpcode().


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