LLVM 22.0.0git
InstCombineSimplifyDemanded.cpp File Reference

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "instcombine"

Functions

static bool ShrinkDemandedConstant (Instruction *I, unsigned OpNo, const APInt &Demanded)
 Check to see if the specified operand of the specified instruction is a constant integer.
static ValuesimplifyShiftSelectingPackedElement (Instruction *I, const APInt &DemandedMask, InstCombinerImpl &IC, unsigned Depth)
 Let N = 2 * M.
static unsigned getBitWidth (Type *Ty, const DataLayout &DL)
 Returns the bitwidth of the given scalar or pointer type.
static ConstantgetFPClassConstant (Type *Ty, FPClassTest Mask)
 For floating-point classes that resolve to a single bit pattern, return that value.

Variables

static cl::opt< boolVerifyKnownBits ("instcombine-verify-known-bits", cl::desc("Verify that computeKnownBits() and " "SimplifyDemandedBits() are consistent"), cl::Hidden, cl::init(false))
static cl::opt< unsignedSimplifyDemandedVectorEltsDepthLimit ("instcombine-simplify-vector-elts-depth", cl::desc("Depth limit when simplifying vector instructions and their operands"), cl::Hidden, cl::init(10))

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "instcombine"

Definition at line 26 of file InstCombineSimplifyDemanded.cpp.

Function Documentation

◆ getBitWidth()

unsigned getBitWidth ( Type * Ty,
const DataLayout & DL )
static

Returns the bitwidth of the given scalar or pointer type.

For vector types, returns the element type's bitwidth.

Definition at line 121 of file InstCombineSimplifyDemanded.cpp.

References llvm::BitWidth, and DL.

◆ getFPClassConstant()

Constant * getFPClassConstant ( Type * Ty,
FPClassTest Mask )
static

◆ ShrinkDemandedConstant()

bool ShrinkDemandedConstant ( Instruction * I,
unsigned OpNo,
const APInt & Demanded )
static

Check to see if the specified operand of the specified instruction is a constant integer.

If so, check to see if there are any bits set in the constant that are not demanded. If so, shrink the constant and return true.

Definition at line 43 of file InstCombineSimplifyDemanded.cpp.

References assert(), llvm::CallingConv::C, I, llvm::PatternMatch::m_APInt(), and llvm::PatternMatch::match().

Referenced by llvm::TargetLowering::ShrinkDemandedConstant(), llvm::TargetLowering::SimplifyDemandedBits(), and llvm::InstCombinerImpl::SimplifyDemandedUseBits().

◆ simplifyShiftSelectingPackedElement()

Value * simplifyShiftSelectingPackedElement ( Instruction * I,
const APInt & DemandedMask,
InstCombinerImpl & IC,
unsigned Depth )
static

Let N = 2 * M.

Given an N-bit integer representing a pack of two M-bit integers, we can select one of the packed integers by right-shifting by either zero or M (which is the most straightforward to check if M is a power of 2), and then isolating the lower M bits. In this case, we can represent the shift as a select on whether the shr amount is nonzero.

Definition at line 70 of file InstCombineSimplifyDemanded.cpp.

References assert(), llvm::InstCombiner::Builder, llvm::InstCombiner::computeKnownBits(), llvm::IRBuilderBase::CreateICmpEQ(), llvm::IRBuilderBase::CreateSelectWithUnknownProfile(), DEBUG_TYPE, llvm::Depth, llvm::APInt::getActiveBits(), llvm::KnownBits::getMaxValue(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::Value::getType(), I, llvm::APInt::isIntN(), llvm::isPowerOf2_64(), llvm::Lower, llvm::PatternMatch::m_c_DisjointOr(), llvm::PatternMatch::m_ConstantInt(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), Select, llvm::Upper, and llvm::KnownBits::Zero.

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

Variable Documentation

◆ SimplifyDemandedVectorEltsDepthLimit

cl::opt< unsigned > SimplifyDemandedVectorEltsDepthLimit("instcombine-simplify-vector-elts-depth", cl::desc( "Depth limit when simplifying vector instructions and their operands"), cl::Hidden, cl::init(10)) ( "instcombine-simplify-vector-elts-depth" ,
cl::desc( "Depth limit when simplifying vector instructions and their operands") ,
cl::Hidden ,
cl::init(10)  )
static

◆ VerifyKnownBits

cl::opt< bool > VerifyKnownBits("instcombine-verify-known-bits", cl::desc("Verify that computeKnownBits() and " "SimplifyDemandedBits() are consistent"), cl::Hidden, cl::init(false)) ( "instcombine-verify-known-bits" ,
cl::desc("Verify that computeKnownBits() and " "SimplifyDemandedBits() are consistent") ,
cl::Hidden ,
cl::init(false)  )
static