|
LLVM
4.0.0
|
#include "InstCombineInternal.h"#include "llvm/Analysis/InstructionSimplify.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/PatternMatch.h"Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "instcombine" |
Functions | |
| static Value * | simplifyValueKnownNonZero (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 Constant * | getLogBase2Vector (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 Value * | dyn_castZExtVal (Value *V, Type *Ty) |
| dyn_castZExtVal - Checks if V is a zext or constant that can be truncated to Ty without losing bits. More... | |
| static Instruction * | foldUDivPow2Cst (Value *Op0, Value *Op1, const BinaryOperator &I, InstCombiner &IC) |
| static Instruction * | foldUDivNegCst (Value *Op0, Value *Op1, const BinaryOperator &I, InstCombiner &IC) |
| static Instruction * | foldUDivShl (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 Instruction * | CvtFDivConstToReciprocal (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... | |
| #define DEBUG_TYPE "instcombine" |
Definition at line 22 of file InstCombineMulDivRem.cpp.
|
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 1279 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().
|
static |
Detect pattern log2(Y * 0.5) with corresponding fast math flags.
Definition at line 476 of file InstCombineMulDivRem.cpp.
References llvm::dyn_cast(), llvm::CallInst::getArgOperand(), llvm::IntrinsicInst::getIntrinsicID(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Value::hasOneUse(), llvm::Instruction::hasUnsafeAlgebra(), I, llvm::PatternMatch::m_SpecificFP(), and llvm::PatternMatch::match().
Referenced by llvm::InstCombiner::visitFMul().
dyn_castZExtVal - Checks if V is a zext or constant that can be truncated to Ty without losing bits.
Definition at line 990 of file InstCombineMulDivRem.cpp.
References C, getBitWidth(), and llvm::ConstantExpr::getTrunc().
Referenced by llvm::InstCombiner::visitUDiv(), and llvm::InstCombiner::visitURem().
|
static |
Definition at line 1041 of file InstCombineMulDivRem.cpp.
References llvm::InstCombiner::Builder, llvm::SelectInst::Create(), llvm::IRBuilder< T, Inserter >::CreateICmpULT(), llvm::ConstantInt::get(), llvm::Constant::getNullValue(), and llvm::Value::getType().
Referenced by visitUDivOperand().
|
static |
Definition at line 1030 of file InstCombineMulDivRem.cpp.
References C, llvm::ConstantInt::get(), llvm::Value::getType(), llvm::Instruction::isExact(), llvm::APInt::logBase2(), and llvm::Instruction::setIsExact().
Referenced by visitUDivOperand().
|
static |
Definition at line 1051 of file InstCombineMulDivRem.cpp.
References llvm::InstCombiner::Builder, llvm::IRBuilder< T, Inserter >::CreateAdd(), llvm::IRBuilder< T, Inserter >::CreateZExt(), llvm::ConstantInt::get(), llvm::Value::getType(), llvm::Instruction::isExact(), llvm_unreachable, llvm::APInt::logBase2(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), N, and llvm::Instruction::setIsExact().
Referenced by visitUDivOperand().
|
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 119 of file InstCombineMulDivRem.cpp.
References E, 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().
Definition at line 503 of file InstCombineMulDivRem.cpp.
References C, E, llvm::Constant::getAggregateElement(), llvm::Value::getType(), llvm::ConstantFP::getValueAPF(), llvm::Type::getVectorNumElements(), I, llvm::APFloat::isFiniteNonZero(), and llvm::Type::isVectorTy().
Referenced by isFMulOrFDivWithConstant(), and llvm::InstCombiner::visitFMul().
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 535 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 |
True if C2 is a multiple of C1. Quotient contains C2/C1.
Definition at line 92 of file InstCombineMulDivRem.cpp.
References assert(), llvm::APInt::getBitWidth(), llvm::APInt::isAllOnesValue(), llvm::APInt::isMinSignedValue(), llvm::APInt::isMinValue(), llvm::APInt::sdivrem(), and llvm::APInt::udivrem().
Referenced by llvm::InstCombiner::commonIDivTransforms().
Definition at line 518 of file InstCombineMulDivRem.cpp.
References C, E, llvm::Constant::getAggregateElement(), llvm::Value::getType(), llvm::ConstantFP::getValueAPF(), llvm::Type::getVectorNumElements(), I, llvm::APFloat::isNormal(), and llvm::Type::isVectorTy().
Referenced by llvm::InstCombiner::foldFMulConst(), llvm::InstCombiner::visitFDiv(), and llvm::InstCombiner::visitFMul().
|
static |
True if the multiply can not be expressed in an int this size.
Definition at line 80 of file InstCombineMulDivRem.cpp.
References llvm::APInt::smul_ov(), and llvm::APInt::umul_ov().
Referenced by llvm::InstCombiner::commonIDivTransforms().
|
static |
The specific integer value is used in a context where it is known to be non-zero.
If this allows us to simplify the computation, do so and return the new operand, otherwise return null.
Definition at line 28 of file InstCombineMulDivRem.cpp.
References A, B, llvm::InstCombiner::Builder, llvm::IRBuilder< T, Inserter >::CreateShl(), llvm::IRBuilder< T, Inserter >::CreateSub(), llvm::dyn_cast(), llvm::InstCombiner::getAssumptionCache(), llvm::InstCombiner::getDataLayout(), llvm::InstCombiner::getDominatorTree(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Instruction::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), I, llvm::Instruction::isExact(), llvm::isKnownToBeAPowerOfTwo(), llvm::Instruction::isLogicalShift(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::Instruction::setHasNoUnsignedWrap(), llvm::Instruction::setIsExact(), llvm::User::setOperand(), and llvm::NVPTX::PTXLdStInstCode::V2.
Referenced by llvm::InstCombiner::commonIDivTransforms(), and llvm::InstCombiner::commonIRemTransforms().
|
static |
Definition at line 1076 of file InstCombineMulDivRem.cpp.
References C, llvm::Depth, foldUDivNegCst(), foldUDivPow2Cst(), foldUDivShl(), I, llvm::PatternMatch::m_Power2(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), MaxDepth, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), SI, and llvm::SmallVectorTemplateCommon< T >::size().
Referenced by llvm::InstCombiner::visitUDiv().
1.8.6