LLVM  6.0.0svn
Macros | Functions
InstCombineMulDivRem.cpp File Reference
#include "InstCombineInternal.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/PatternMatch.h"
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 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 C2 is a multiple of C1. Quotient contains C2/C1. More...
 
static ConstantgetLogBase2Vector (ConstantDataVector *CV)
 A helper routine of InstCombiner::visitMul(). More...
 
static void detectLog2OfHalf (Value *&Op, Value *&Y, IntrinsicInst *&Log2)
 Detect pattern log2(Y * 0.5) with corresponding fast math flags. More...
 
static bool isFiniteNonZeroFp (Constant *C)
 
static bool isNormalFp (Constant *C)
 
static bool isFMulOrFDivWithConstant (Value *V)
 Helper function of InstCombiner::visitFMul(BinaryOperator(). More...
 
static InstructionfoldUDivPow2Cst (Value *Op0, Value *Op1, const BinaryOperator &I, InstCombiner &IC)
 
static InstructionfoldUDivNegCst (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 InstructionCvtFDivConstToReciprocal (Value *Dividend, Constant *Divisor, bool AllowReciprocal)
 CvtFDivConstToReciprocal tries to convert X/C into X*1/C if C not a special FP value and: 1) 1/C is exact, or 2) reciprocal is allowed. More...
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "instcombine"

Definition at line 22 of file InstCombineMulDivRem.cpp.

Function Documentation

◆ CvtFDivConstToReciprocal()

static Instruction* CvtFDivConstToReciprocal ( Value Dividend,
Constant Divisor,
bool  AllowReciprocal 
)
static

CvtFDivConstToReciprocal tries to convert X/C into X*1/C if C not a special FP value and: 1) 1/C is exact, or 2) reciprocal is allowed.

If the conversion was successful, the simplified expression "X * 1/C" is returned; otherwise, NULL is returned.

Definition at line 1285 of file InstCombineMulDivRem.cpp.

References llvm::lltok::APFloat, llvm::ConstantFP::get(), llvm::Type::getContext(), llvm::APFloat::getExactInverse(), llvm::APFloat::getSemantics(), llvm::Value::getType(), llvm::APFloat::isFiniteNonZero(), and llvm::APFloatBase::rmNearestTiesToEven.

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

◆ detectLog2OfHalf()

static void detectLog2OfHalf ( Value *&  Op,
Value *&  Y,
IntrinsicInst *&  Log2 
)
static

◆ foldUDivNegCst()

static Instruction* foldUDivNegCst ( Value Op0,
Value Op1,
const BinaryOperator I,
InstCombiner IC 
)
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

◆ getLogBase2Vector()

static Constant* getLogBase2Vector ( ConstantDataVector CV)
static

◆ isFiniteNonZeroFp()

static bool isFiniteNonZeroFp ( Constant C)
static

◆ isFMulOrFDivWithConstant()

static bool isFMulOrFDivWithConstant ( Value V)
static

Helper function of InstCombiner::visitFMul(BinaryOperator().

It returns true iff the given value is FMul or FDiv with one and only one operand being a normal constant (i.e. not Zero/NaN/Infinity).

Definition at line 522 of file InstCombineMulDivRem.cpp.

References llvm::dyn_cast(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), I, and isFiniteNonZeroFp().

Referenced by llvm::InstCombiner::foldFMulConst(), and llvm::InstCombiner::visitFMul().

◆ IsMultiple()

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

◆ isNormalFp()

static bool isNormalFp ( Constant C)
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 78 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