LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
InstCombineMulDivRem.cpp File Reference
#include "InstCombine.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/Support/PatternMatch.h"
Include dependency graph for InstCombineMulDivRem.cpp:

Go to the source code of this file.

Functions

static ValuesimplifyValueKnownNonZero (Value *V, InstCombiner &IC)
 
static bool MultiplyOverflows (ConstantInt *C1, ConstantInt *C2, bool sign)
 
static ConstantgetLogBase2Vector (ConstantDataVector *CV)
 A helper routine of InstCombiner::visitMul(). More...
 
static void detectLog2OfHalf (Value *&Op, Value *&Y, IntrinsicInst *&Log2)
 
static bool isFMulOrFDivWithConstant (Value *V)
 
static bool isNormalFp (const ConstantFP *C)
 
static Valuedyn_castZExtVal (Value *V, Type *Ty)
 
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 InstructionCvtFDivConstToReciprocal (Value *Dividend, ConstantFP *Divisor, bool AllowReciprocal)
 

Function Documentation

static Instruction* CvtFDivConstToReciprocal ( Value Dividend,
ConstantFP 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 967 of file InstCombineMulDivRem.cpp.

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

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

static void detectLog2OfHalf ( Value *&  Op,
Value *&  Y,
IntrinsicInst *&  Log2 
)
static
static Value* dyn_castZExtVal ( Value V,
Type Ty 
)
static

dyn_castZExtVal - Checks if V is a zext or constant that can be truncated to Ty without losing bits.

Definition at line 727 of file InstCombineMulDivRem.cpp.

References llvm::CallingConv::C, getBitWidth(), and llvm::ConstantExpr::getTrunc().

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

static Instruction* foldUDivNegCst ( Value Op0,
Value Op1,
const BinaryOperator I,
InstCombiner IC 
)
static
static Instruction* foldUDivPow2Cst ( Value Op0,
Value Op1,
const BinaryOperator I,
InstCombiner IC 
)
static
static Instruction* foldUDivShl ( Value Op0,
Value Op1,
const BinaryOperator I,
InstCombiner IC 
)
static
static Constant* getLogBase2Vector ( ConstantDataVector CV)
static

A helper routine of InstCombiner::visitMul().

If C is a vector of known powers of 2, then this function returns a new vector obtained from C replacing each element with its logBase2. Return a null pointer otherwise.

Definition at line 103 of file InstCombineMulDivRem.cpp.

References llvm::ConstantInt::get(), llvm::ConstantVector::get(), llvm::ConstantDataSequential::getElementAsConstant(), llvm::ConstantDataSequential::getNumElements(), llvm::Value::getType(), I, llvm::APInt::isPowerOf2(), llvm::APInt::logBase2(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), and llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back().

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

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

References llvm::dyn_cast(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::ConstantFP::getValueAPF(), I, and llvm::APFloat::isFiniteNonZero().

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

static bool isNormalFp ( const ConstantFP C)
static
static bool MultiplyOverflows ( ConstantInt C1,
ConstantInt C2,
bool  sign 
)
static
static Value* simplifyValueKnownNonZero ( Value V,
InstCombiner IC 
)
static
static size_t visitUDivOperand ( Value Op0,
Value Op1,
const BinaryOperator I,
SmallVectorImpl< UDivFoldAction > &  Actions,
unsigned  Depth = 0 
)
static