LLVM  13.0.0git
Macros | Functions | Variables
InstCombineMulDivRem.cpp File Reference
#include "InstCombineInternal.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/InstructionSimplify.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/Support/KnownBits.h"
#include "llvm/Transforms/InstCombine/InstCombineWorklist.h"
#include "llvm/Transforms/InstCombine/InstCombiner.h"
#include "llvm/Transforms/Utils/BuildLibCalls.h"
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <utility>
Include dependency graph for InstCombineMulDivRem.cpp:

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. More...
 
static ValuefoldMulSelectToNegate (BinaryOperator &I, InstCombiner::BuilderTy &Builder)
 
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. More...
 
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. More...
 
static InstructionfoldUDivPow2Cst (Value *Op0, Value *Op1, const BinaryOperator &I, InstCombinerImpl &IC)
 
static InstructionfoldUDivShl (Value *Op0, Value *Op1, const BinaryOperator &I, InstCombinerImpl &IC)
 
static size_t visitUDivOperand (Value *Op0, Value *Op1, const BinaryOperator &I, SmallVectorImpl< UDivFoldAction > &Actions, unsigned Depth=0)
 
static InstructionnarrowUDivURem (BinaryOperator &I, InstCombiner::BuilderTy &Builder)
 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). More...
 
static InstructionfoldFDivConstantDivisor (BinaryOperator &I)
 Remove negation and try to convert division into multiplication. More...
 
static InstructionfoldFDivConstantDividend (BinaryOperator &I)
 Remove negation and try to reassociate constant math. More...
 
static InstructionfoldFDivPowDivisor (BinaryOperator &I, InstCombiner::BuilderTy &Builder)
 Negate the exponent of pow/exp to fold division-by-pow() into multiply. More...
 

Variables

static const unsigned MaxDepth = 6
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "instcombine"

Definition at line 45 of file InstCombineMulDivRem.cpp.

Function Documentation

◆ foldFDivConstantDividend()

static Instruction* foldFDivConstantDividend ( BinaryOperator I)
static

◆ foldFDivConstantDivisor()

static Instruction* foldFDivConstantDivisor ( 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 1278 of file InstCombineMulDivRem.cpp.

References llvm::AMDGPU::HSAMD::Kernel::Key::Args, Builder, llvm::BinaryOperator::CreateFMulFMF(), I, and powi().

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

◆ foldMulSelectToNegate()

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

◆ foldUDivPow2Cst()

static Instruction* foldUDivPow2Cst ( Value Op0,
Value Op1,
const BinaryOperator I,
InstCombinerImpl IC 
)
static

◆ foldUDivShl()

static Instruction* foldUDivShl ( Value Op0,
Value Op1,
const BinaryOperator I,
InstCombinerImpl IC 
)
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 690 of file InstCombineMulDivRem.cpp.

References C1.

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

◆ narrowUDivURem()

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

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).

Definition at line 966 of file InstCombineMulDivRem.cpp.

References Builder, D, llvm::ConstantExpr::getTrunc(), llvm::ConstantExpr::getZExt(), I, llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), N, X, and Y.

Referenced by llvm::InstCombinerImpl::visitUDiv(), and llvm::InstCombinerImpl::visitURem().

◆ simplifyValueKnownNonZero()

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

◆ visitUDivOperand()

static size_t visitUDivOperand ( Value Op0,
Value Op1,
const BinaryOperator I,
SmallVectorImpl< UDivFoldAction > &  Actions,
unsigned  Depth = 0 
)
static

Variable Documentation

◆ MaxDepth

const unsigned MaxDepth = 6
static