LLVM API Documentation
#include "InstCombine.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/PatternMatch.h"
Go to the source code of this file.
#define DEBUG_TYPE "instcombine" |
Definition at line 22 of file InstCombineMulDivRem.cpp.
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] |
Definition at line 323 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::LibFunc::log2, llvm::PatternMatch::m_SpecificFP(), and llvm::PatternMatch::match().
Referenced by llvm::InstCombiner::visitFMul().
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] |
Definition at line 885 of file InstCombineMulDivRem.cpp.
References llvm::InstCombiner::Builder, llvm::SelectInst::Create(), llvm::IRBuilder< preserveNames, T, Inserter >::CreateICmpULT(), llvm::ConstantInt::get(), llvm::Constant::getNullValue(), and llvm::Value::getType().
Referenced by visitUDivOperand().
static Instruction* foldUDivPow2Cst | ( | Value * | Op0, |
Value * | Op1, | ||
const BinaryOperator & | I, | ||
InstCombiner & | IC | ||
) | [static] |
Definition at line 875 of file InstCombineMulDivRem.cpp.
References llvm::CallingConv::C, llvm::ConstantInt::get(), llvm::Value::getType(), llvm::BinaryOperator::isExact(), llvm::APInt::logBase2(), llvm::LShr, and llvm::BinaryOperator::setIsExact().
Referenced by visitUDivOperand().
static Instruction* foldUDivShl | ( | Value * | Op0, |
Value * | Op1, | ||
const BinaryOperator & | I, | ||
InstCombiner & | IC | ||
) | [static] |
Definition at line 894 of file InstCombineMulDivRem.cpp.
References llvm::InstCombiner::Builder, llvm::IRBuilder< preserveNames, T, Inserter >::CreateAdd(), llvm::IRBuilder< preserveNames, T, Inserter >::CreateZExt(), llvm::ConstantInt::get(), llvm::User::getOperand(), llvm::Value::getType(), llvm::BinaryOperator::isExact(), llvm::APInt::logBase2(), llvm::LShr, N, and llvm::BinaryOperator::setIsExact().
Referenced by visitUDivOperand().
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] |
Definition at line 351 of file InstCombineMulDivRem.cpp.
References llvm::CallingConv::C, llvm::dyn_cast(), 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().
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] |
Definition at line 366 of file InstCombineMulDivRem.cpp.
References llvm::CallingConv::C, llvm::dyn_cast(), 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 bool MultiplyOverflows | ( | ConstantInt * | C1, |
ConstantInt * | C2, | ||
bool | sign | ||
) | [static] |
MultiplyOverflows - True if the multiply can not be expressed in an int this size.
Definition at line 84 of file InstCombineMulDivRem.cpp.
References llvm::ConstantInt::getBitWidth(), llvm::APInt::getLowBitsSet(), llvm::APInt::getSignedMaxValue(), llvm::APInt::getSignedMinValue(), llvm::ConstantInt::getValue(), llvm::APInt::sext(), llvm::APInt::sgt(), llvm::APInt::slt(), llvm::APInt::ugt(), and llvm::APInt::zext().
Referenced by llvm::InstCombiner::commonIDivTransforms().
static Value* simplifyValueKnownNonZero | ( | Value * | V, |
InstCombiner & | IC, | ||
Instruction * | CxtI | ||
) | [static] |
simplifyValueKnownNonZero - 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 llvm::ARM_PROC::A, llvm::InstCombiner::Builder, llvm::IRBuilder< preserveNames, T, Inserter >::CreateShl(), llvm::IRBuilder< preserveNames, T, Inserter >::CreateSub(), llvm::InstCombiner::getAssumptionTracker(), llvm::InstCombiner::getDominatorTree(), llvm::Value::hasOneUse(), I, llvm::isKnownToBeAPowerOfTwo(), llvm::LShr, llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and llvm::NVPTX::PTXLdStInstCode::V2.
Referenced by llvm::InstCombiner::commonIDivTransforms(), and llvm::InstCombiner::commonIRemTransforms().
static size_t visitUDivOperand | ( | Value * | Op0, |
Value * | Op1, | ||
const BinaryOperator & | I, | ||
SmallVectorImpl< UDivFoldAction > & | Actions, | ||
unsigned | Depth = 0 |
||
) | [static] |
Definition at line 916 of file InstCombineMulDivRem.cpp.
References llvm::CallingConv::C, 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(), and llvm::SmallVectorTemplateCommon< T >::size().
Referenced by llvm::InstCombiner::visitUDiv().