LLVM
8.0.1
|
#include "InstCombineInternal.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/MemoryBuiltins.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalVariable.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/LLVMContext.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/Statepoint.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Support/AtomicOrdering.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/KnownBits.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/InstCombine/InstCombineWorklist.h"
#include "llvm/Transforms/Utils/SimplifyLibCalls.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstring>
#include <utility>
#include <vector>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "instcombine" |
Functions | |
STATISTIC (NumSimplified, "Number of library calls simplified") | |
static Type * | getPromotedType (Type *Ty) |
Return the specified type promoted as it would be to pass though a va_arg area. More... | |
static Constant * | getNegativeIsTrueBoolVec (ConstantDataVector *V) |
Return a constant boolean vector that has true elements in all positions where the input constant data vector has an element with the sign bit set. More... | |
static Value * | simplifyX86immShift (const IntrinsicInst &II, InstCombiner::BuilderTy &Builder) |
static Value * | simplifyX86varShift (const IntrinsicInst &II, InstCombiner::BuilderTy &Builder) |
static Value * | simplifyX86pack (IntrinsicInst &II, bool IsSigned) |
static Value * | simplifyX86round (IntrinsicInst &II, InstCombiner::BuilderTy &Builder) |
static Value * | simplifyX86movmsk (const IntrinsicInst &II, InstCombiner::BuilderTy &Builder) |
static Value * | simplifyX86insertps (const IntrinsicInst &II, InstCombiner::BuilderTy &Builder) |
static Value * | simplifyX86extrq (IntrinsicInst &II, Value *Op0, ConstantInt *CILength, ConstantInt *CIIndex, InstCombiner::BuilderTy &Builder) |
Attempt to simplify SSE4A EXTRQ/EXTRQI instructions using constant folding or conversion to a shuffle vector. More... | |
static Value * | simplifyX86insertq (IntrinsicInst &II, Value *Op0, Value *Op1, APInt APLength, APInt APIndex, InstCombiner::BuilderTy &Builder) |
Attempt to simplify SSE4A INSERTQ/INSERTQI instructions using constant folding or conversion to a shuffle vector. More... | |
static Value * | simplifyX86pshufb (const IntrinsicInst &II, InstCombiner::BuilderTy &Builder) |
Attempt to convert pshufb* to shufflevector if the mask is constant. More... | |
static Value * | simplifyX86vpermilvar (const IntrinsicInst &II, InstCombiner::BuilderTy &Builder) |
Attempt to convert vpermilvar* to shufflevector if the mask is constant. More... | |
static Value * | simplifyX86vpermv (const IntrinsicInst &II, InstCombiner::BuilderTy &Builder) |
Attempt to convert vpermd/vpermps to shufflevector if the mask is constant. More... | |
static Value * | simplifyX86vpcom (const IntrinsicInst &II, InstCombiner::BuilderTy &Builder, bool IsSigned) |
Decode XOP integer vector comparison intrinsics. More... | |
static bool | maskIsAllOneOrUndef (Value *Mask) |
static Value * | simplifyMaskedLoad (const IntrinsicInst &II, InstCombiner::BuilderTy &Builder) |
static Instruction * | simplifyMaskedStore (IntrinsicInst &II, InstCombiner &IC) |
static Instruction * | simplifyMaskedGather (IntrinsicInst &II, InstCombiner &IC) |
static Instruction * | simplifyInvariantGroupIntrinsic (IntrinsicInst &II, InstCombiner &IC) |
This function transforms launder.invariant.group and strip.invariant.group like: launder(launder(x)) -> launder(x) (the result is not the argument) launder(strip(x)) -> launder(x) strip(strip(x)) -> strip(x) (the result is not the argument) strip(launder(x)) -> strip(x) This is legal because it preserves the most recent information about the presence or absence of invariant.group. More... | |
static Instruction * | simplifyMaskedScatter (IntrinsicInst &II, InstCombiner &IC) |
static Instruction * | foldCttzCtlz (IntrinsicInst &II, InstCombiner &IC) |
static Instruction * | foldCtpop (IntrinsicInst &II, InstCombiner &IC) |
static Instruction * | simplifyX86MaskedLoad (IntrinsicInst &II, InstCombiner &IC) |
static bool | simplifyX86MaskedStore (IntrinsicInst &II, InstCombiner &IC) |
static APFloat | fmed3AMDGCN (const APFloat &Src0, const APFloat &Src1, const APFloat &Src2) |
static Value * | simplifyNeonTbl1 (const IntrinsicInst &II, InstCombiner::BuilderTy &Builder) |
Convert a table lookup to shufflevector if the mask is constant. More... | |
static Value * | simplifyNeonVld1 (const IntrinsicInst &II, unsigned MemAlign, InstCombiner::BuilderTy &Builder) |
Convert a vector load intrinsic into a simple llvm load instruction. More... | |
static bool | haveSameOperands (const IntrinsicInst &I, const IntrinsicInst &E, unsigned NumOperands) |
static bool | removeTriviallyEmptyRange (IntrinsicInst &I, unsigned StartID, unsigned EndID, InstCombiner &IC) |
static Instruction * | SimplifyNVVMIntrinsic (IntrinsicInst *II, InstCombiner &IC) |
static Instruction * | canonicalizeConstantArg0ToArg1 (CallInst &Call) |
static bool | isSafeToEliminateVarargsCast (const CallSite CS, const DataLayout &DL, const CastInst *const CI, const int ix) |
If this cast does not affect the value passed through the varargs area, we can eliminate the use of the cast. More... | |
static IntrinsicInst * | findInitTrampolineFromAlloca (Value *TrampMem) |
static IntrinsicInst * | findInitTrampolineFromBB (IntrinsicInst *AdjustTramp, Value *TrampMem) |
static IntrinsicInst * | findInitTrampoline (Value *Callee) |
Variables | |
static cl::opt< unsigned > | GuardWideningWindow ("instcombine-guard-widening-window", cl::init(3), cl::desc("How wide an instruction window to bypass looking for " "another guard")) |
#define DEBUG_TYPE "instcombine" |
Definition at line 72 of file InstCombineCalls.cpp.
|
static |
Definition at line 1819 of file InstCombineCalls.cpp.
References assert(), llvm::CallBase::getArgOperand(), llvm::CallBase::getNumArgOperands(), and llvm::CallBase::setArgOperand().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 4169 of file InstCombineCalls.cpp.
References llvm::AttributeList::addParamAttribute(), llvm::Intrinsic::adjust_trampoline, llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::arg_begin(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::arg_end(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::arg_size(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::args(), llvm::AMDGPU::HSAMD::Kernel::Key::Args, assert(), llvm::AMDGPU::HSAMD::Kernel::Key::Attrs, llvm::Attribute::ByVal, Callee, llvm::CallInst::Create(), llvm::InvokeInst::Create(), llvm::CastInst::CreateBitOrPointerCast(), llvm::dbgs(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::doesNotThrow(), llvm::dyn_cast(), E, llvm::SmallVectorBase::empty(), llvm::Instruction::extractProfTotalWeight(), findInitTrampolineFromAlloca(), findInitTrampolineFromBB(), llvm::Attribute::get(), llvm::FunctionType::get(), llvm::AttributeSet::get(), llvm::AttributeList::get(), llvm::UndefValue::get(), llvm::CallBase::getArgOperand(), llvm::Function::getAttributes(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getAttributes(), llvm::ConstantExpr::getBitCast(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getCalledValue(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getCallingConv(), llvm::CastInst::getCastOpcode(), llvm::Value::getContext(), llvm::Instruction::getDebugLoc(), llvm::PointerType::getElementType(), llvm::AttributeList::getFnAttributes(), llvm::Instruction::getFunction(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getInstruction(), llvm::Type::getInt1PtrTy(), llvm::IntrinsicInst::getIntrinsicID(), llvm::Constant::getNullValue(), llvm::FunctionType::getNumParams(), llvm::User::getOperand(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getOperandBundlesAsDefs(), llvm::AttributeList::getParamAttributes(), llvm::FunctionType::getParamType(), llvm::Type::getPointerElementType(), getPromotedType(), llvm::FunctionType::getReturnType(), llvm::ConstantInt::getTrue(), llvm::Value::getType(), llvm::GlobalValue::getType(), llvm::PointerType::getUnqual(), llvm::GlobalValue::getValueType(), llvm::AttributeSet::hasAttribute(), llvm::AttributeList::hasAttrSomewhere(), llvm::AttributeList::hasParamAttribute(), llvm::Value::hasValueHandle(), I, llvm::Attribute::InAlloca, llvm::isAllocLikeFn(), llvm::CastInst::isBitOrNoopPointerCastable(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::isConvergent(), llvm::AttributeList::isEmpty(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::isInAllocaArgument(), llvm::isKnownNonZero(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::isMustTailCall(), isSafeToEliminateVarargsCast(), llvm::Type::isSized(), llvm::Type::isStructTy(), llvm::FunctionType::isVarArg(), llvm::Type::isVoidTy(), IT, LLVM_DEBUG, NC, llvm::Attribute::Nest, llvm::Attribute::NonNull, llvm::NullPointerIsDefined(), llvm::AttrBuilder::overlaps(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::paramHasAttr(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::AttrBuilder::remove(), llvm::SmallVectorImpl< T >::reserve(), llvm::AttributeList::ReturnIndex, llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::setAttributes(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::setCalledFunction(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::setCallingConv(), llvm::Instruction::setDebugLoc(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::setDoesNotThrow(), llvm::Value::setName(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::setNotConvergent(), llvm::SmallVectorBase::size(), llvm::Value::stripPointerCasts(), llvm::Attribute::StructRet, llvm::AttributeFuncs::typeIncompatible(), llvm::Value::use_empty(), llvm::Value::users(), llvm::ValueHandleBase::ValueIsDeleted(), llvm::ValueHandleBase::ValueIsRAUWd(), and llvm::RISCVFenceField::W.
|
static |
Definition at line 4109 of file InstCombineCalls.cpp.
References llvm::Intrinsic::adjust_trampoline, llvm::dyn_cast(), llvm::IntrinsicInst::getIntrinsicID(), llvm::User::getOperand(), llvm::Value::hasOneUse(), llvm::Intrinsic::init_trampoline, llvm::Value::stripPointerCasts(), llvm::BitmaskEnumDetail::Underlying(), llvm::Value::user_back(), and llvm::Value::users().
Referenced by findInitTrampoline().
|
static |
Definition at line 4148 of file InstCombineCalls.cpp.
References llvm::BasicBlock::begin(), E, llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Instruction::getParent(), I, llvm::Intrinsic::init_trampoline, and llvm::Instruction::mayWriteToMemory().
Referenced by findInitTrampoline().
|
static |
Definition at line 1440 of file InstCombineCalls.cpp.
References assert(), llvm::APFloatBase::cmpEqual, llvm::APFloatBase::cmpUnordered, llvm::APFloat::compare(), and llvm::maxnum().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 1327 of file InstCombineCalls.cpp.
References assert(), llvm::InstCombiner::computeKnownBits(), llvm::KnownBits::countMaxPopulation(), llvm::KnownBits::countMinPopulation(), llvm::Intrinsic::ctpop, llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::ConstantAsMetadata::get(), llvm::MDNode::get(), llvm::CallBase::getArgOperand(), llvm::Value::getContext(), llvm::IntrinsicInst::getIntrinsicID(), llvm::Instruction::getMetadata(), IT, LowAndHigh, llvm::LLVMContext::MD_range, and llvm::Instruction::setMetadata().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 1276 of file InstCombineCalls.cpp.
References assert(), llvm::InstCombiner::Builder, C, llvm::InstCombiner::computeKnownBits(), llvm::KnownBits::countMaxLeadingZeros(), llvm::KnownBits::countMaxTrailingZeros(), llvm::KnownBits::countMinLeadingZeros(), llvm::KnownBits::countMinTrailingZeros(), llvm::Intrinsic::ctlz, llvm::Intrinsic::cttz, llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::ConstantAsMetadata::get(), llvm::MDNode::get(), llvm::CallBase::getArgOperand(), llvm::InstCombiner::getAssumptionCache(), llvm::Value::getContext(), llvm::InstCombiner::getDataLayout(), llvm::InstCombiner::getDominatorTree(), llvm::IntrinsicInst::getIntrinsicID(), llvm::Instruction::getMetadata(), llvm::IRBuilderBase::getTrue(), llvm::Value::getType(), llvm::isKnownNonZero(), llvm::APInt::isNullValue(), IT, LowAndHigh, llvm::PatternMatch::m_One(), llvm::PatternMatch::match(), llvm::LLVMContext::MD_range, llvm::KnownBits::One, llvm::InstCombiner::replaceInstUsesWith(), llvm::Instruction::setMetadata(), and llvm::User::setOperand().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Return a constant boolean vector that has true elements in all positions where the input constant data vector has an element with the sign bit set.
Definition at line 94 of file InstCombineCalls.cpp.
References assert(), llvm::dyn_cast(), E, llvm::IntegerType::get(), llvm::ConstantInt::get(), llvm::PointerType::get(), llvm::ConstantVector::get(), llvm::Value::getContext(), llvm::MemIntrinsicBase< Derived >::getDest(), llvm::ConstantDataSequential::getElementAsConstant(), llvm::ConstantDataSequential::getElementType(), llvm::Type::getInt1Ty(), llvm::getKnownAlignment(), llvm::ConstantInt::getLimitedValue(), llvm::Constant::getNullValue(), llvm::ConstantDataSequential::getNumElements(), llvm::MemIntrinsicBase< Derived >::getRawDest(), llvm::ConstantInt::getType(), I, llvm::Type::isIntegerTy(), llvm::isPowerOf2_32(), isZero(), llvm::LLVMContext::MD_access_group, llvm::LLVMContext::MD_mem_parallel_loop_access, llvm::LLVMContext::MD_tbaa, llvm::LLVMContext::MD_tbaa_struct, MI, llvm::SmallVectorTemplateBase< T >::push_back(), llvm::LoadInst::setAlignment(), llvm::StoreInst::setAlignment(), llvm::Instruction::setMetadata(), llvm::LoadInst::setOrdering(), llvm::StoreInst::setOrdering(), llvm::LoadInst::setVolatile(), llvm::StoreInst::setVolatile(), Size, and llvm::Unordered.
Referenced by simplifyX86MaskedLoad(), simplifyX86MaskedStore(), and llvm::InstCombiner::visitCallInst().
Return the specified type promoted as it would be to pass though a va_arg area.
Definition at line 84 of file InstCombineCalls.cpp.
References llvm::Type::getContext(), and llvm::Type::getInt32Ty().
Referenced by findInitTrampoline().
|
static |
Definition at line 1521 of file InstCombineCalls.cpp.
References assert(), llvm::CallBase::getArgOperand(), and llvm::CallBase::getNumArgOperands().
Referenced by removeTriviallyEmptyRange().
|
static |
If this cast does not affect the value passed through the varargs area, we can eliminate the use of the cast.
Definition at line 4059 of file InstCombineCalls.cpp.
References From, llvm::CallBase::getCalledFunction(), llvm::User::getOperand(), llvm::Value::getType(), llvm::DataLayout::getTypeAllocSize(), I, llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::isByValOrInAllocaArgument(), llvm::isGCRelocate(), llvm::isGCResult(), llvm::CastInst::isLosslessCast(), llvm::Type::isSized(), llvm::isStatepoint(), llvm::LibCallSimplifier::optimizeCall(), and llvm::Value::use_empty().
Referenced by findInitTrampoline().
Definition at line 1176 of file InstCombineCalls.cpp.
References llvm::dyn_cast(), E, I, and llvm::BitmaskEnumDetail::Mask().
Referenced by simplifyMaskedLoad().
|
static |
Definition at line 1540 of file InstCombineCalls.cpp.
References assert(), E, llvm::BasicBlock::end(), llvm::InstCombiner::eraseInstFromFunction(), llvm::IntrinsicInst::getIntrinsicID(), llvm::Instruction::getParent(), and haveSameOperands().
Referenced by llvm::InstCombiner::visitCallInst(), llvm::InstCombiner::visitVACopyInst(), and llvm::InstCombiner::visitVAStartInst().
|
static |
This function transforms launder.invariant.group and strip.invariant.group like: launder(launder(x)) -> launder(x) (the result is not the argument) launder(strip(x)) -> launder(x) strip(strip(x)) -> strip(x) (the result is not the argument) strip(launder(x)) -> strip(x) This is legal because it preserves the most recent information about the presence or absence of invariant.group.
Definition at line 1241 of file InstCombineCalls.cpp.
References Arg, llvm::InstCombiner::Builder, llvm::IRBuilder< T, Inserter >::CreateAddrSpaceCast(), llvm::IRBuilder< T, Inserter >::CreateBitCast(), llvm::IRBuilder< T, Inserter >::CreateLaunderInvariantGroup(), llvm::IRBuilder< T, Inserter >::CreateStripInvariantGroup(), llvm::CallBase::getArgOperand(), llvm::IntrinsicInst::getIntrinsicID(), llvm::Type::getPointerAddressSpace(), llvm::Value::getType(), llvm::Intrinsic::launder_invariant_group, llvm_unreachable, llvm::Intrinsic::strip_invariant_group, llvm::Value::stripPointerCasts(), and llvm::Value::stripPointerCastsAndInvariantGroups().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 1224 of file InstCombineCalls.cpp.
References llvm::dyn_cast(), llvm::CallBase::getArgOperand(), and llvm::InstCombiner::replaceInstUsesWith().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 1192 of file InstCombineCalls.cpp.
References llvm::IRBuilder< T, Inserter >::CreateAlignedLoad(), llvm::CallBase::getArgOperand(), and maskIsAllOneOrUndef().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 1267 of file InstCombineCalls.cpp.
References llvm::dyn_cast(), llvm::InstCombiner::eraseInstFromFunction(), and llvm::CallBase::getArgOperand().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 1205 of file InstCombineCalls.cpp.
References llvm::dyn_cast(), llvm::InstCombiner::eraseInstFromFunction(), and llvm::CallBase::getArgOperand().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Convert a table lookup to shufflevector if the mask is constant.
This could benefit tbl1 if the mask is { 7,6,5,4,3,2,1,0 }, in which case we could lower the shufflevector with rev64 instructions as it's actually a byte reverse.
Definition at line 1461 of file InstCombineCalls.cpp.
References C, llvm::IRBuilder< T, Inserter >::CreateShuffleVector(), llvm::dyn_cast(), llvm::ConstantDataVector::get(), llvm::CallBase::getArgOperand(), llvm::Value::getContext(), llvm::Constant::getNullValue(), llvm::Value::getType(), I, llvm::makeArrayRef(), and llvm::NVPTX::PTXLdStInstCode::V2.
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Convert a vector load intrinsic into a simple llvm load instruction.
This is beneficial when the underlying object being addressed comes from a constant, since we get constant-folding for free.
Definition at line 1500 of file InstCombineCalls.cpp.
References llvm::IRBuilder< T, Inserter >::CreateAlignedLoad(), llvm::IRBuilder< T, Inserter >::CreateBitCast(), llvm::dyn_cast(), llvm::PointerType::get(), llvm::CallBase::getArgOperand(), llvm::ConstantInt::getLimitedValue(), llvm::Value::getType(), and llvm::isPowerOf2_32().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 1563 of file InstCombineCalls.cpp.
References llvm::CallBase::arg_operands(), llvm::AMDGPU::HSAMD::Kernel::Key::Args, llvm::Intrinsic::ceil, llvm::BinaryOperator::Create(), llvm::CastInst::Create(), llvm::CallInst::Create(), llvm::Intrinsic::fabs, llvm::Intrinsic::floor, llvm::Intrinsic::fma, FtzEnabled, llvm::ConstantFP::get(), llvm::CallBase::getArgOperand(), llvm::Intrinsic::getDeclaration(), llvm::Function::getFnAttribute(), llvm::Instruction::getFunction(), llvm::IntrinsicInst::getIntrinsicID(), llvm::Instruction::getModule(), llvm::Value::getName(), llvm::Value::getType(), llvm::Attribute::getValueAsString(), llvm_unreachable, llvm::Intrinsic::maxnum, llvm::Intrinsic::minnum, llvm::Intrinsic::nvvm_add_rn_d, llvm::Intrinsic::nvvm_add_rn_f, llvm::Intrinsic::nvvm_add_rn_ftz_f, llvm::Intrinsic::nvvm_ceil_d, llvm::Intrinsic::nvvm_ceil_f, llvm::Intrinsic::nvvm_ceil_ftz_f, llvm::Intrinsic::nvvm_d2i_rz, llvm::Intrinsic::nvvm_d2ll_rz, llvm::Intrinsic::nvvm_d2ui_rz, llvm::Intrinsic::nvvm_d2ull_rz, llvm::Intrinsic::nvvm_div_rn_d, llvm::Intrinsic::nvvm_div_rn_f, llvm::Intrinsic::nvvm_div_rn_ftz_f, llvm::Intrinsic::nvvm_f2i_rz, llvm::Intrinsic::nvvm_f2ll_rz, llvm::Intrinsic::nvvm_f2ui_rz, llvm::Intrinsic::nvvm_f2ull_rz, llvm::Intrinsic::nvvm_fabs_d, llvm::Intrinsic::nvvm_fabs_f, llvm::Intrinsic::nvvm_fabs_ftz_f, llvm::Intrinsic::nvvm_floor_d, llvm::Intrinsic::nvvm_floor_f, llvm::Intrinsic::nvvm_floor_ftz_f, llvm::Intrinsic::nvvm_fma_rn_d, llvm::Intrinsic::nvvm_fma_rn_f, llvm::Intrinsic::nvvm_fma_rn_ftz_f, llvm::Intrinsic::nvvm_fmax_d, llvm::Intrinsic::nvvm_fmax_f, llvm::Intrinsic::nvvm_fmax_ftz_f, llvm::Intrinsic::nvvm_fmin_d, llvm::Intrinsic::nvvm_fmin_f, llvm::Intrinsic::nvvm_fmin_ftz_f, llvm::Intrinsic::nvvm_i2d_rz, llvm::Intrinsic::nvvm_i2f_rz, llvm::Intrinsic::nvvm_ll2d_rz, llvm::Intrinsic::nvvm_ll2f_rz, llvm::Intrinsic::nvvm_mul_rn_d, llvm::Intrinsic::nvvm_mul_rn_f, llvm::Intrinsic::nvvm_mul_rn_ftz_f, llvm::Intrinsic::nvvm_rcp_rn_d, llvm::Intrinsic::nvvm_rcp_rn_f, llvm::Intrinsic::nvvm_rcp_rn_ftz_f, llvm::Intrinsic::nvvm_round_d, llvm::Intrinsic::nvvm_round_f, llvm::Intrinsic::nvvm_round_ftz_f, llvm::Intrinsic::nvvm_sqrt_f, llvm::Intrinsic::nvvm_sqrt_rn_d, llvm::Intrinsic::nvvm_sqrt_rn_f, llvm::Intrinsic::nvvm_sqrt_rn_ftz_f, llvm::Intrinsic::nvvm_trunc_d, llvm::Intrinsic::nvvm_trunc_f, llvm::Intrinsic::nvvm_trunc_ftz_f, llvm::Intrinsic::nvvm_ui2d_rz, llvm::Intrinsic::nvvm_ui2f_rz, llvm::Intrinsic::nvvm_ull2d_rz, llvm::Intrinsic::nvvm_ull2f_rz, llvm::Intrinsic::round, llvm::Intrinsic::sqrt, and llvm::Intrinsic::trunc.
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Attempt to simplify SSE4A EXTRQ/EXTRQI instructions using constant folding or conversion to a shuffle vector.
Definition at line 815 of file InstCombineCalls.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Key::Args, llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::Constant::getAggregateElement(), llvm::Value::getContext(), llvm::Type::getInt64Ty(), llvm::ConstantInt::getValue(), llvm::APInt::getZExtValue(), and llvm::APInt::zextOrTrunc().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 268 of file InstCombineCalls.cpp.
References assert(), llvm::IRBuilder< T, Inserter >::CreateAShr(), llvm::IRBuilder< T, Inserter >::CreateLShr(), llvm::IRBuilder< T, Inserter >::CreateShl(), llvm::IRBuilder< T, Inserter >::CreateVectorSplat(), llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::ConstantAggregateZero::get(), llvm::CallBase::getArgOperand(), llvm::IntrinsicInst::getIntrinsicID(), llvm::APInt::isNullValue(), llvm_unreachable, llvm::APInt::uge(), llvm::Intrinsic::x86_avx2_psll_d, llvm::Intrinsic::x86_avx2_psll_q, llvm::Intrinsic::x86_avx2_psll_w, llvm::Intrinsic::x86_avx2_pslli_d, llvm::Intrinsic::x86_avx2_pslli_q, llvm::Intrinsic::x86_avx2_pslli_w, llvm::Intrinsic::x86_avx2_psra_d, llvm::Intrinsic::x86_avx2_psra_w, llvm::Intrinsic::x86_avx2_psrai_d, llvm::Intrinsic::x86_avx2_psrai_w, llvm::Intrinsic::x86_avx2_psrl_d, llvm::Intrinsic::x86_avx2_psrl_q, llvm::Intrinsic::x86_avx2_psrl_w, llvm::Intrinsic::x86_avx2_psrli_d, llvm::Intrinsic::x86_avx2_psrli_q, llvm::Intrinsic::x86_avx2_psrli_w, llvm::Intrinsic::x86_avx512_psll_d_512, llvm::Intrinsic::x86_avx512_psll_q_512, llvm::Intrinsic::x86_avx512_psll_w_512, llvm::Intrinsic::x86_avx512_pslli_d_512, llvm::Intrinsic::x86_avx512_pslli_q_512, llvm::Intrinsic::x86_avx512_pslli_w_512, llvm::Intrinsic::x86_avx512_psra_d_512, llvm::Intrinsic::x86_avx512_psra_q_128, llvm::Intrinsic::x86_avx512_psra_q_256, llvm::Intrinsic::x86_avx512_psra_q_512, llvm::Intrinsic::x86_avx512_psra_w_512, llvm::Intrinsic::x86_avx512_psrai_d_512, llvm::Intrinsic::x86_avx512_psrai_q_128, llvm::Intrinsic::x86_avx512_psrai_q_256, llvm::Intrinsic::x86_avx512_psrai_q_512, llvm::Intrinsic::x86_avx512_psrai_w_512, llvm::Intrinsic::x86_avx512_psrl_d_512, llvm::Intrinsic::x86_avx512_psrl_q_512, llvm::Intrinsic::x86_avx512_psrl_w_512, llvm::Intrinsic::x86_avx512_psrli_d_512, llvm::Intrinsic::x86_avx512_psrli_q_512, llvm::Intrinsic::x86_avx512_psrli_w_512, llvm::Intrinsic::x86_sse2_psll_d, llvm::Intrinsic::x86_sse2_psll_q, llvm::Intrinsic::x86_sse2_psll_w, llvm::Intrinsic::x86_sse2_pslli_d, llvm::Intrinsic::x86_sse2_pslli_q, llvm::Intrinsic::x86_sse2_pslli_w, llvm::Intrinsic::x86_sse2_psra_d, llvm::Intrinsic::x86_sse2_psra_w, llvm::Intrinsic::x86_sse2_psrai_d, llvm::Intrinsic::x86_sse2_psrai_w, llvm::Intrinsic::x86_sse2_psrl_d, llvm::Intrinsic::x86_sse2_psrl_q, llvm::Intrinsic::x86_sse2_psrl_w, llvm::Intrinsic::x86_sse2_psrli_d, llvm::Intrinsic::x86_sse2_psrli_q, llvm::Intrinsic::x86_sse2_psrli_w, and llvm::APInt::zextOrTrunc().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 756 of file InstCombineCalls.cpp.
References assert(), llvm::IRBuilder< T, Inserter >::CreateShuffleVector(), llvm::dyn_cast(), llvm::ConstantAggregateZero::get(), llvm::CallBase::getArgOperand(), llvm::SequentialType::getNumElements(), and llvm::Value::getType().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Attempt to simplify SSE4A INSERTQ/INSERTQI instructions using constant folding or conversion to a shuffle vector.
Definition at line 909 of file InstCombineCalls.cpp.
References llvm::APInt::getZExtValue(), and llvm::APInt::zextOrTrunc().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 1359 of file InstCombineCalls.cpp.
References llvm::InstCombiner::Builder, llvm::IRBuilder< T, Inserter >::CreateBitCast(), llvm::IRBuilderBase::CreateMaskedLoad(), llvm::dyn_cast(), llvm::PointerType::get(), getNegativeIsTrueBoolVec(), llvm::Constant::getNullValue(), llvm::User::getOperand(), llvm::Value::getType(), llvm::BitmaskEnumDetail::Mask(), and llvm::InstCombiner::replaceInstUsesWith().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 1395 of file InstCombineCalls.cpp.
References llvm::InstCombiner::Builder, llvm::IRBuilder< T, Inserter >::CreateBitCast(), llvm::IRBuilderBase::CreateMaskedStore(), llvm::dyn_cast(), llvm::InstCombiner::eraseInstFromFunction(), llvm::PointerType::get(), llvm::IntrinsicInst::getIntrinsicID(), getNegativeIsTrueBoolVec(), llvm::User::getOperand(), llvm::Value::getType(), llvm::BitmaskEnumDetail::Mask(), and llvm::Intrinsic::x86_sse2_maskmov_dqu.
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 700 of file InstCombineCalls.cpp.
References Arg, C, llvm::IRBuilder< T, Inserter >::CreateBitCast(), llvm::IRBuilder< T, Inserter >::CreateZExtOrTrunc(), llvm::dyn_cast(), E, llvm::CallBase::getArgOperand(), llvm::Value::getContext(), llvm::Constant::getIntegerValue(), llvm::Type::getIntNTy(), llvm::Constant::getNullValue(), llvm::Type::getPrimitiveSizeInBits(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), I, llvm::Type::isIntOrIntVectorTy(), llvm::Type::isVectorTy(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::peekThroughBitcast(), and X.
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 526 of file InstCombineCalls.cpp.
References assert(), llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::APInt::getAllOnesValue(), llvm::CallBase::getArgOperand(), llvm::APInt::getBitWidth(), llvm::APInt::getNullValue(), llvm::Type::getPrimitiveSizeInBits(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::APInt::getSignedMaxValue(), llvm::APInt::getSignedMinValue(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::APInt::isIntN(), llvm::APInt::isNegative(), llvm::APInt::isSignedIntN(), llvm::SmallVectorTemplateBase< T >::push_back(), and llvm::APInt::trunc().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Attempt to convert pshufb* to shufflevector if the mask is constant.
Definition at line 1004 of file InstCombineCalls.cpp.
References assert(), llvm::IRBuilder< T, Inserter >::CreateShuffleVector(), llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::Constant::getAggregateElement(), llvm::CallBase::getArgOperand(), llvm::Value::getContext(), llvm::Type::getInt32Ty(), llvm::Constant::getNullValue(), llvm::Value::getType(), I, llvm::makeArrayRef(), and llvm::NVPTX::PTXLdStInstCode::V2.
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 602 of file InstCombineCalls.cpp.
References Arg, C, llvm::Intrinsic::ceil, llvm::IRBuilder< T, Inserter >::CreateAnd(), llvm::IRBuilder< T, Inserter >::CreateBitCast(), llvm::IRBuilder< T, Inserter >::CreateExtractElement(), llvm::IRBuilder< T, Inserter >::CreateICmp(), llvm::IRBuilder< T, Inserter >::CreateInsertElement(), llvm::IRBuilder< T, Inserter >::CreateSelect(), llvm::IRBuilder< T, Inserter >::CreateShuffleVector(), llvm::IRBuilderBase::CreateUnaryIntrinsic(), llvm::dyn_cast(), llvm::Intrinsic::floor, llvm::VectorType::get(), llvm::Constant::getAllOnesValue(), llvm::CallBase::getArgOperand(), getBitWidth(), llvm::IRBuilderBase::getInt1Ty(), llvm::IRBuilderBase::getIntNTy(), llvm::IntrinsicInst::getIntrinsicID(), llvm::Constant::getNullValue(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::ConstantInt::getZExtValue(), llvm::CmpInst::ICMP_NE, llvm::makeArrayRef(), llvm::BitmaskEnumDetail::Mask(), llvm::Intrinsic::x86_avx512_mask_rndscale_pd_128, llvm::Intrinsic::x86_avx512_mask_rndscale_pd_256, llvm::Intrinsic::x86_avx512_mask_rndscale_pd_512, llvm::Intrinsic::x86_avx512_mask_rndscale_ps_128, llvm::Intrinsic::x86_avx512_mask_rndscale_ps_256, llvm::Intrinsic::x86_avx512_mask_rndscale_ps_512, llvm::Intrinsic::x86_avx512_mask_rndscale_sd, llvm::Intrinsic::x86_avx512_mask_rndscale_ss, llvm::Intrinsic::x86_sse41_round_sd, and llvm::Intrinsic::x86_sse41_round_ss.
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 402 of file InstCombineCalls.cpp.
References llvm::all_of(), assert(), llvm::IRBuilder< T, Inserter >::CreateAShr(), llvm::IRBuilder< T, Inserter >::CreateLShr(), llvm::IRBuilder< T, Inserter >::CreateShl(), llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::CallBase::getArgOperand(), llvm::IntrinsicInst::getIntrinsicID(), llvm::Constant::getNullValue(), llvm::Value::getType(), llvm::APInt::getZExtValue(), I, llvm_unreachable, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::APInt::uge(), llvm::Intrinsic::x86_avx2_psllv_d, llvm::Intrinsic::x86_avx2_psllv_d_256, llvm::Intrinsic::x86_avx2_psllv_q, llvm::Intrinsic::x86_avx2_psllv_q_256, llvm::Intrinsic::x86_avx2_psrav_d, llvm::Intrinsic::x86_avx2_psrav_d_256, llvm::Intrinsic::x86_avx2_psrlv_d, llvm::Intrinsic::x86_avx2_psrlv_d_256, llvm::Intrinsic::x86_avx2_psrlv_q, llvm::Intrinsic::x86_avx2_psrlv_q_256, llvm::Intrinsic::x86_avx512_psllv_d_512, llvm::Intrinsic::x86_avx512_psllv_q_512, llvm::Intrinsic::x86_avx512_psllv_w_128, llvm::Intrinsic::x86_avx512_psllv_w_256, llvm::Intrinsic::x86_avx512_psllv_w_512, llvm::Intrinsic::x86_avx512_psrav_d_512, llvm::Intrinsic::x86_avx512_psrav_q_128, llvm::Intrinsic::x86_avx512_psrav_q_256, llvm::Intrinsic::x86_avx512_psrav_q_512, llvm::Intrinsic::x86_avx512_psrav_w_128, llvm::Intrinsic::x86_avx512_psrav_w_256, llvm::Intrinsic::x86_avx512_psrav_w_512, llvm::Intrinsic::x86_avx512_psrlv_d_512, llvm::Intrinsic::x86_avx512_psrlv_q_512, llvm::Intrinsic::x86_avx512_psrlv_w_128, llvm::Intrinsic::x86_avx512_psrlv_w_256, and llvm::Intrinsic::x86_avx512_psrlv_w_512.
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Decode XOP integer vector comparison intrinsics.
Definition at line 1138 of file InstCombineCalls.cpp.
References llvm::CmpInst::BAD_ICMP_PREDICATE, llvm::IRBuilder< T, Inserter >::CreateICmp(), llvm::IRBuilder< T, Inserter >::CreateSExtOrTrunc(), llvm::CallBase::getArgOperand(), llvm::ConstantInt::getSigned(), llvm::Value::getType(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, and llvm::CmpInst::ICMP_ULT.
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Attempt to convert vpermilvar* to shufflevector if the mask is constant.
Definition at line 1051 of file InstCombineCalls.cpp.
References assert(), llvm::IRBuilder< T, Inserter >::CreateShuffleVector(), llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::Constant::getAggregateElement(), llvm::CallBase::getArgOperand(), llvm::Value::getContext(), llvm::Type::getInt32Ty(), llvm::APInt::getLoBits(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), I, llvm::APInt::lshrInPlace(), llvm::makeArrayRef(), llvm::NVPTX::PTXLdStInstCode::V2, and llvm::APInt::zextOrTrunc().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Attempt to convert vpermd/vpermps to shufflevector if the mask is constant.
Definition at line 1101 of file InstCombineCalls.cpp.
References assert(), llvm::IRBuilder< T, Inserter >::CreateShuffleVector(), llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::Constant::getAggregateElement(), llvm::CallBase::getArgOperand(), llvm::Value::getContext(), llvm::Type::getInt32Ty(), llvm::Value::getType(), I, llvm::makeArrayRef(), Size, and llvm::NVPTX::PTXLdStInstCode::V2.
Referenced by llvm::InstCombiner::visitCallInst().
STATISTIC | ( | NumSimplified | , |
"Number of library calls simplified" | |||
) |