LLVM 20.0.0git
Macros | Functions | Variables
InstCombineMulDivRem.cpp File Reference
#include "InstCombineInternal.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Transforms/InstCombine/InstCombiner.h"
#include "llvm/Transforms/Utils/BuildLibCalls.h"
#include <cassert>
#include "llvm/Transforms/Utils/InstructionWorklist.h"

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 ValuetakeLog2 (IRBuilderBase &Builder, Value *Op, unsigned Depth, bool AssumeNonZero, bool DoFold)
 
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 InstructionsimplifyIRemMulShl (BinaryOperator &I, InstCombinerImpl &IC)
 

Variables

static const unsigned MaxDepth = 6
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "instcombine"

Definition at line 37 of file InstCombineMulDivRem.cpp.

Function Documentation

◆ foldFDivConstantDividend()

static Instruction * foldFDivConstantDividend ( BinaryOperator I)
static

◆ foldFDivPowDivisor()

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

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

Definition at line 1858 of file InstCombineMulDivRem.cpp.

References llvm::BinaryOperator::CreateFMulFMF(), llvm::IRBuilderBase::CreateFNegFMF(), llvm::IRBuilderBase::CreateIntrinsic(), llvm::IRBuilderBase::CreateNeg(), I, and II.

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

◆ foldFDivSqrtDivisor()

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

◆ foldIDivShl()

static Value * foldIDivShl ( BinaryOperator I,
InstCombiner::BuilderTy Builder 
)
static

◆ foldMulSelectToNegate()

static Value * foldMulSelectToNegate ( BinaryOperator I,
InstCombiner::BuilderTy Builder 
)
static

◆ foldMulShl1()

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

◆ isMultiple()

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

◆ multiplyOverflows()

static 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 1052 of file InstCombineMulDivRem.cpp.

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

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

◆ narrowUDivURem()

static Instruction * narrowUDivURem ( BinaryOperator I,
InstCombinerImpl IC 
)
static

◆ simplifyIRemMulShl()

static Instruction * simplifyIRemMulShl ( BinaryOperator I,
InstCombinerImpl IC 
)
static

◆ simplifyValueKnownNonZero()

static Value * simplifyValueKnownNonZero ( Value V,
InstCombinerImpl IC,
Instruction CxtI 
)
static

◆ takeLog2()

static Value * takeLog2 ( IRBuilderBase Builder,
Value Op,
unsigned  Depth,
bool  AssumeNonZero,
bool  DoFold 
)
static

Variable Documentation

◆ MaxDepth

const unsigned MaxDepth = 6
static