LLVM
8.0.1
|
#include "InstCombineInternal.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/ValueTracking.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/Operator.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/KnownBits.h"
#include <cassert>
#include <utility>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "instcombine" |
Functions | |
static Value * | checkForNegativeOperand (BinaryOperator &I, InstCombiner::BuilderTy &Builder) |
static bool | MatchMul (Value *E, Value *&Op, APInt &C) |
static bool | MatchRem (Value *E, Value *&Op, APInt &C, bool &IsSigned) |
static bool | MatchDiv (Value *E, Value *&Op, APInt &C, bool IsSigned) |
static bool | MulWillOverflow (APInt &C0, APInt &C1, bool IsSigned) |
static Instruction * | canonicalizeLowbitMask (BinaryOperator &I, InstCombiner::BuilderTy &Builder) |
Fold (1 << NBits) - 1 Into: ~(-(1 << NBits)) Because a 'not' is better for bit-tracking analysis and other transforms than an 'add'. More... | |
static Instruction * | factorizeFAddFSub (BinaryOperator &I, InstCombiner::BuilderTy &Builder) |
Factor a common operand out of fadd/fsub of fmul/fdiv. More... | |
#define DEBUG_TYPE "instcombine" |
Definition at line 39 of file InstCombineAddSub.cpp.
|
static |
Fold (1 << NBits) - 1 Into: ~(-(1 << NBits)) Because a 'not' is better for bit-tracking analysis and other transforms than an 'add'.
The new shl is always nsw, and is nuw if old and
was.
Definition at line 1017 of file InstCombineAddSub.cpp.
References llvm::BinaryOperator::CreateNot(), llvm::IRBuilder< T, Inserter >::CreateShl(), llvm::Constant::getAllOnesValue(), llvm::Value::getName(), llvm::Value::getType(), llvm::Instruction::hasNoUnsignedWrap(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Value(), and llvm::PatternMatch::match().
Referenced by llvm::InstCombiner::visitAdd().
|
static |
Definition at line 770 of file InstCombineAddSub.cpp.
References llvm::MCID::Add, llvm::AddOne(), C, llvm::APInt::countTrailingZeros(), llvm::CastInst::Create(), llvm::SelectInst::Create(), CreateAdd(), llvm::IRBuilder< T, Inserter >::CreateAnd(), llvm::IRBuilder< T, Inserter >::CreateOr(), llvm::IRBuilder< T, Inserter >::CreateSub(), llvm::ConstantInt::get(), llvm::APInt::getBitWidth(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::Instruction::hasNoSignedWrap(), llvm::Instruction::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), llvm::APInt::isMinSignedValue(), llvm::APInt::isNegative(), llvm::APInt::isOneValue(), llvm::APInt::isSignMask(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_NUWAdd(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), llvm::APInt::sext(), llvm::APInt::sge(), llvm::SubOne(), std::swap(), llvm::APInt::trunc(), X, and Y.
Referenced by llvm::InstCombiner::visitAdd().
|
static |
Factor a common operand out of fadd/fsub of fmul/fdiv.
Definition at line 1232 of file InstCombineAddSub.cpp.
References assert(), C, llvm::IRBuilder< T, Inserter >::CreateFAddFMF(), llvm::BinaryOperator::CreateFDivFMF(), llvm::BinaryOperator::CreateFMulFMF(), llvm::IRBuilder< T, Inserter >::CreateFSubFMF(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Instruction::hasAllowReassoc(), llvm::Instruction::hasNoSignedZeros(), llvm::APFloat::isNormal(), llvm::PatternMatch::m_APFloat(), llvm::PatternMatch::m_c_FMul(), llvm::PatternMatch::m_FDiv(), llvm::PatternMatch::m_FMul(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), X, and Y.
Referenced by llvm::InstCombiner::visitFAdd(), and llvm::InstCombiner::visitFSub().
Definition at line 948 of file InstCombineAddSub.cpp.
References llvm::APInt::getBitWidth(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_SDiv(), llvm::PatternMatch::m_UDiv(), llvm::PatternMatch::m_Value(), and llvm::PatternMatch::match().
Referenced by MulWillOverflow().
Definition at line 908 of file InstCombineAddSub.cpp.
References llvm::APInt::getBitWidth(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_Mul(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Value(), and llvm::PatternMatch::match().
Referenced by MulWillOverflow().
Definition at line 926 of file InstCombineAddSub.cpp.
References llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_SRem(), llvm::PatternMatch::m_URem(), llvm::PatternMatch::m_Value(), and llvm::PatternMatch::match().
Referenced by MulWillOverflow().
Definition at line 969 of file InstCombineAddSub.cpp.
References llvm::ConstantInt::get(), llvm::Type::getContext(), llvm::User::getOperand(), llvm::Value::getType(), MatchDiv(), MatchMul(), MatchRem(), llvm::APInt::smul_ov(), llvm::APInt::umul_ov(), and X.