LLVM 22.0.0git
InstCombineMulDivRem.cpp File Reference

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "instcombine"

Functions

static ValuesimplifyValueKnownNonZero (Value *V, InstCombinerImpl &IC, Instruction &CxtI)
 The specific integer value is used in a context where it is known to be non-zero.
static ValuefoldMulSelectToNegate (BinaryOperator &I, InstCombiner::BuilderTy &Builder)
static ValuefoldMulShl1 (BinaryOperator &Mul, bool CommuteOperands, InstCombiner::BuilderTy &Builder)
 Reduce integer multiplication patterns that contain a (+/-1 << Z) factor.
static bool getFSqrtDivOptPattern (Instruction *Div, SmallPtrSetImpl< Instruction * > &R1, SmallPtrSetImpl< Instruction * > &R2)
static bool isFSqrtDivToFMulLegal (Instruction *X, SmallPtrSetImpl< Instruction * > &R1, SmallPtrSetImpl< Instruction * > &R2)
static bool multiplyOverflows (const APInt &C1, const APInt &C2, APInt &Product, bool IsSigned)
 True if the multiply can not be expressed in an int this size.
static bool isMultiple (const APInt &C1, const APInt &C2, APInt &Quotient, bool IsSigned)
 True if C1 is a multiple of C2. Quotient contains C1/C2.
static ValuefoldIDivShl (BinaryOperator &I, InstCombiner::BuilderTy &Builder)
static InstructionnarrowUDivURem (BinaryOperator &I, InstCombinerImpl &IC)
 If we have zero-extended operands of an unsigned div or rem, we may be able to narrow the operation (sink the zext below the math).
static InstructionfoldFDivConstantDividend (BinaryOperator &I)
 Remove negation and try to reassociate constant math.
static InstructionfoldFDivPowDivisor (BinaryOperator &I, InstCombiner::BuilderTy &Builder)
 Negate the exponent of pow/exp to fold division-by-pow() into multiply.
static InstructionfoldFDivSqrtDivisor (BinaryOperator &I, InstCombiner::BuilderTy &Builder)
 Convert div to mul if we have an sqrt divisor iff sqrt's operand is a fdiv instruction.
static InstructionconvertFSqrtDivIntoFMul (CallInst *CI, Instruction *X, const SmallPtrSetImpl< Instruction * > &R1, const SmallPtrSetImpl< Instruction * > &R2, InstCombiner::BuilderTy &B, InstCombinerImpl *IC)
static InstructionsimplifyIRemMulShl (BinaryOperator &I, InstCombinerImpl &IC)

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "instcombine"

Definition at line 38 of file InstCombineMulDivRem.cpp.

Function Documentation

◆ convertFSqrtDivIntoFMul()

◆ foldFDivConstantDividend()

◆ foldFDivPowDivisor()

Instruction * foldFDivPowDivisor ( BinaryOperator & I,
InstCombiner::BuilderTy & Builder )
static

Negate the exponent of pow/exp to fold division-by-pow() into multiply.

Definition at line 1972 of file InstCombineMulDivRem.cpp.

References llvm::BinaryOperator::CreateFMulFMF(), llvm::dyn_cast(), I, and II.

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

◆ foldFDivSqrtDivisor()

Instruction * foldFDivSqrtDivisor ( BinaryOperator & I,
InstCombiner::BuilderTy & Builder )
static

Convert div to mul if we have an sqrt divisor iff sqrt's operand is a fdiv instruction.

Definition at line 2018 of file InstCombineMulDivRem.cpp.

References llvm::BinaryOperator::CreateFMulFMF(), llvm::dyn_cast(), I, II, llvm::PatternMatch::m_FDiv(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and Y.

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

◆ foldIDivShl()

◆ foldMulSelectToNegate()

◆ foldMulShl1()

Value * foldMulShl1 ( BinaryOperator & Mul,
bool CommuteOperands,
InstCombiner::BuilderTy & Builder )
static

◆ getFSqrtDivOptPattern()

◆ isFSqrtDivToFMulLegal()

◆ isMultiple()

bool isMultiple ( const APInt & C1,
const APInt & C2,
APInt & Quotient,
bool IsSigned )
static

◆ multiplyOverflows()

bool multiplyOverflows ( const APInt & C1,
const APInt & C2,
APInt & Product,
bool IsSigned )
static

True if the multiply can not be expressed in an int this size.

Definition at line 1160 of file InstCombineMulDivRem.cpp.

References llvm::APInt::smul_ov(), and llvm::APInt::umul_ov().

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

◆ narrowUDivURem()

◆ simplifyIRemMulShl()

◆ simplifyValueKnownNonZero()