LLVM API Documentation

Defines | Functions
InstCombineMulDivRem.cpp File Reference
#include "InstCombine.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.

Defines

#define DEBUG_TYPE   "instcombine"

Functions

static ValuesimplifyValueKnownNonZero (Value *V, InstCombiner &IC, Instruction *CxtI)
static bool MultiplyOverflows (ConstantInt *C1, ConstantInt *C2, bool sign)
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.
static ConstantgetLogBase2Vector (ConstantDataVector *CV)
 A helper routine of InstCombiner::visitMul().
static void detectLog2OfHalf (Value *&Op, Value *&Y, IntrinsicInst *&Log2)
static bool isFiniteNonZeroFp (Constant *C)
static bool isNormalFp (Constant *C)
static bool isFMulOrFDivWithConstant (Value *V)
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, Constant *Divisor, bool AllowReciprocal)

Define Documentation

#define DEBUG_TYPE   "instcombine"

Definition at line 22 of file InstCombineMulDivRem.cpp.


Function Documentation

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 1086 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::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 835 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 125 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 isFiniteNonZeroFp ( Constant C) [static]
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 383 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().

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

True if C2 is a multiple of C1. Quotient contains C2/C1.

Definition at line 106 of file InstCombineMulDivRem.cpp.

References llvm::APInt::getBitWidth(), llvm::APInt::sdivrem(), and llvm::APInt::udivrem().

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

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