LLVM  8.0.1
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/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, InstCombiner &IC, Instruction &CxtI)
 The specific integer value is used in a context where it is known to be non-zero. More...
 
static ConstantgetLogBase2 (Type *Ty, Constant *C)
 A helper routine of InstCombiner::visitMul(). More...
 
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, InstCombiner &IC)
 
static InstructionfoldUDivShl (Value *Op0, Value *Op1, const BinaryOperator &I, InstCombiner &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...
 

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

◆ foldUDivPow2Cst()

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

◆ foldUDivShl()

static Instruction* foldUDivShl ( Value Op0,
Value Op1,
const BinaryOperator I,
InstCombiner IC 
)
static

◆ getLogBase2()

static Constant* getLogBase2 ( Type Ty,
Constant C 
)
static

A helper routine of InstCombiner::visitMul().

If C is a scalar/vector of known powers of 2, then this function returns a new scalar/vector obtained from logBase2 of C. Return a null pointer otherwise.

Definition at line 103 of file InstCombineMulDivRem.cpp.

References E, llvm::ConstantInt::get(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::Constant::getAggregateElement(), llvm::Type::getScalarType(), llvm::Type::getVectorNumElements(), I, llvm::APInt::isPowerOf2(), llvm::Type::isVectorTy(), llvm::APInt::logBase2(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), and llvm::SmallVectorTemplateBase< T >::push_back().

Referenced by foldUDivPow2Cst(), foldUDivShl(), and llvm::InstCombiner::visitMul().

◆ 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 559 of file InstCombineMulDivRem.cpp.

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

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

◆ narrowUDivURem()

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

◆ simplifyValueKnownNonZero()

static Value* simplifyValueKnownNonZero ( Value V,
InstCombiner 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

Definition at line 724 of file InstCombineMulDivRem.cpp.