|
LLVM
7.0.0
|
#include "InstCombineInternal.h"#include "llvm/ADT/APFloat.h"#include "llvm/ADT/APInt.h"#include "llvm/ADT/SmallVector.h"#include "llvm/Analysis/InstructionSimplify.h"#include "llvm/IR/BasicBlock.h"#include "llvm/IR/Constant.h"#include "llvm/IR/Constants.h"#include "llvm/IR/InstrTypes.h"#include "llvm/IR/Instruction.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/Intrinsics.h"#include "llvm/IR/Operator.h"#include "llvm/IR/PatternMatch.h"#include "llvm/IR/Type.h"#include "llvm/IR/Value.h"#include "llvm/Support/Casting.h"#include "llvm/Support/ErrorHandling.h"#include "llvm/Support/KnownBits.h"#include "llvm/Transforms/InstCombine/InstCombineWorklist.h"#include "llvm/Transforms/Utils/BuildLibCalls.h"#include <cassert>#include <cstddef>#include <cstdint>#include <utility>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 Constant * | getLogBase2 (Type *Ty, Constant *C) |
| A helper routine of InstCombiner::visitMul(). 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 C1 is a multiple of C2. Quotient contains C1/C2. More... | |
| static Instruction * | foldUDivPow2Cst (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 * | narrowUDivURem (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 Instruction * | foldFDivConstantDivisor (BinaryOperator &I) |
| Remove negation and try to convert division into multiplication. More... | |
| static Instruction * | foldFDivConstantDividend (BinaryOperator &I) |
| Remove negation and try to reassociate constant math. More... | |
Variables | |
| static const unsigned | MaxDepth = 6 |
| #define DEBUG_TYPE "instcombine" |
Definition at line 45 of file InstCombineMulDivRem.cpp.
|
static |
Remove negation and try to reassociate constant math.
Definition at line 1140 of file InstCombineMulDivRem.cpp.
References C, llvm::BinaryOperator::CreateFDivFMF(), llvm::ConstantExpr::getFDiv(), llvm::ConstantExpr::getFMul(), llvm::ConstantExpr::getFNeg(), llvm::User::getOperand(), llvm::Instruction::hasAllowReassoc(), llvm::Instruction::hasAllowReciprocal(), llvm::Constant::isNormalFP(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_FDiv(), llvm::PatternMatch::m_FMul(), llvm::PatternMatch::m_FNeg(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and X.
Referenced by llvm::InstCombiner::visitFDiv().
|
static |
Remove negation and try to convert division into multiplication.
Definition at line 1111 of file InstCombineMulDivRem.cpp.
References C, llvm::BinaryOperator::CreateFDivFMF(), llvm::BinaryOperator::CreateFMulFMF(), llvm::ConstantFP::get(), llvm::ConstantExpr::getFDiv(), llvm::ConstantExpr::getFNeg(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Instruction::hasAllowReciprocal(), llvm::Constant::hasExactInverseFP(), I, llvm::Constant::isNormalFP(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_FNeg(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and X.
Referenced by llvm::InstCombiner::visitFDiv().
|
static |
Definition at line 823 of file InstCombineMulDivRem.cpp.
References getLogBase2(), llvm::Value::getType(), llvm::Instruction::isExact(), llvm_unreachable, and llvm::Instruction::setIsExact().
Referenced by visitUDivOperand().
|
static |
Definition at line 836 of file InstCombineMulDivRem.cpp.
References llvm::InstCombiner::Builder, llvm::IRBuilder< T, Inserter >::CreateAdd(), llvm::IRBuilder< T, Inserter >::CreateZExt(), getLogBase2(), llvm::Value::getType(), llvm::Instruction::isExact(), llvm_unreachable, llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), N, and llvm::Instruction::setIsExact().
Referenced by visitUDivOperand().
A helper routine of InstCombiner::visitMul().
If C is a scalar/vector of known powers of 2, then this function returns a new scalar/vector obtained from logBase2 of C. Return a null pointer otherwise.
Definition at line 103 of file InstCombineMulDivRem.cpp.
References E, llvm::ConstantInt::get(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::Constant::getAggregateElement(), llvm::Type::getScalarType(), llvm::Type::getVectorNumElements(), I, llvm::APInt::isPowerOf2(), llvm::Type::isVectorTy(), llvm::APInt::logBase2(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), and llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back().
Referenced by foldUDivPow2Cst(), foldUDivShl(), and llvm::InstCombiner::visitMul().
|
static |
True if C1 is a multiple of C2. Quotient contains C1/C2.
Definition at line 632 of file InstCombineMulDivRem.cpp.
References assert(), llvm::APInt::getBitWidth(), llvm::APInt::isAllOnesValue(), llvm::APInt::isMinSignedValue(), llvm::APInt::isNullValue(), llvm::APInt::sdivrem(), and llvm::APInt::udivrem().
Referenced by llvm::InstCombiner::commonIDivTransforms().
|
static |
True if the multiply can not be expressed in an int this size.
Definition at line 624 of file InstCombineMulDivRem.cpp.
References llvm::APInt::smul_ov(), and llvm::APInt::umul_ov().
Referenced by llvm::InstCombiner::commonIDivTransforms().
|
static |
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).
Definition at line 896 of file InstCombineMulDivRem.cpp.
References C, llvm::IRBuilder< T, Inserter >::CreateBinOp(), D, llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::ConstantExpr::getZExt(), llvm::Value::hasOneUse(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), N, X, and Y.
Referenced by llvm::InstCombiner::visitUDiv(), and llvm::InstCombiner::visitURem().
|
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 50 of file InstCombineMulDivRem.cpp.
References B, llvm::InstCombiner::Builder, llvm::IRBuilder< T, Inserter >::CreateShl(), llvm::IRBuilder< T, Inserter >::CreateSub(), llvm::dyn_cast(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Instruction::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), I, llvm::Instruction::isExact(), llvm::InstCombiner::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 862 of file InstCombineMulDivRem.cpp.
References llvm::Depth, foldUDivPow2Cst(), foldUDivShl(), I, llvm::PatternMatch::m_Power2(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), SI, and llvm::SmallVectorBase::size().
Referenced by llvm::InstCombiner::visitUDiv().
Definition at line 789 of file InstCombineMulDivRem.cpp.
1.8.13