|
LLVM
4.0.0
|
#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/Statistic.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/Twine.h"#include "llvm/Analysis/InstructionSimplify.h"#include "llvm/Analysis/MemoryBuiltins.h"#include "llvm/Analysis/ValueTracking.h"#include "llvm/IR/BasicBlock.h"#include "llvm/IR/CallSite.h"#include "llvm/IR/Constant.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/Value.h"#include "llvm/IR/ValueHandle.h"#include "llvm/Support/Casting.h"#include "llvm/Support/Debug.h"#include "llvm/Support/MathExtras.h"#include "llvm/Transforms/Utils/Local.h"#include "llvm/Transforms/Utils/SimplifyLibCalls.h"#include <algorithm>#include <cassert>#include <cstdint>#include <cstring>#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 Type * | reduceToSingleValueType (Type *T) |
| Given an aggregate type which ultimately holds a single scalar element, like {{{type}}} or [1 x type], return type. 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 * | 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 * | simplifyX86vperm2 (const IntrinsicInst &II, InstCombiner::BuilderTy &Builder) |
| The shuffle mask for a perm2*128 selects any two halves of two 256-bit source vectors, unless a zero bit is set. More... | |
| static Value * | simplifyX86vpcom (const IntrinsicInst &II, InstCombiner::BuilderTy &Builder, bool IsSigned) |
| Decode XOP integer vector comparison intrinsics. More... | |
| static Value * | emitX86MaskSelect (Value *Mask, Value *Op0, Value *Op1, InstCombiner::BuilderTy &Builder) |
| static Value * | simplifyMinnumMaxnum (const IntrinsicInst &II) |
| 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 * | simplifyMaskedScatter (IntrinsicInst &II, InstCombiner &IC) |
| static Instruction * | foldCttzCtlz (IntrinsicInst &II, InstCombiner &IC) |
| static Instruction * | simplifyX86MaskedLoad (IntrinsicInst &II, InstCombiner &IC) |
| static bool | simplifyX86MaskedStore (IntrinsicInst &II, InstCombiner &IC) |
| static bool | haveSameOperands (const IntrinsicInst &I, const IntrinsicInst &E, unsigned NumOperands) |
| static bool | removeTriviallyEmptyRange (IntrinsicInst &I, unsigned StartID, unsigned EndID, InstCombiner &IC) |
| 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) |
| #define DEBUG_TYPE "instcombine" |
Definition at line 59 of file InstCombineCalls.cpp.
|
static |
Definition at line 1039 of file InstCombineCalls.cpp.
References C, llvm::IRBuilder< T, Inserter >::CreateBitCast(), llvm::IRBuilder< T, Inserter >::CreateSelect(), llvm::IRBuilder< T, Inserter >::CreateShuffleVector(), llvm::VectorType::get(), getBitWidth(), llvm::IRBuilderBase::getInt1Ty(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), i, and llvm::makeArrayRef().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 2922 of file InstCombineCalls.cpp.
References llvm::dyn_cast(), findInitTrampolineFromAlloca(), findInitTrampolineFromBB(), llvm::IntrinsicInst::getIntrinsicID(), llvm::User::getOperand(), IT(), and llvm::Value::stripPointerCasts().
|
static |
Definition at line 2861 of file InstCombineCalls.cpp.
References llvm::dyn_cast(), llvm::IntrinsicInst::getIntrinsicID(), llvm::User::getOperand(), llvm::Value::hasOneUse(), llvm::Value::stripPointerCasts(), llvm::BitmaskEnumDetail::Underlying(), llvm::Value::user_back(), and llvm::Value::users().
Referenced by findInitTrampoline().
|
static |
Definition at line 2900 of file InstCombineCalls.cpp.
References llvm::BasicBlock::begin(), E, llvm::IntrinsicInst::getIntrinsicID(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::User::getOperand(), llvm::Instruction::getParent(), I, and llvm::Instruction::mayWriteToMemory().
Referenced by findInitTrampoline().
|
static |
Definition at line 1209 of file InstCombineCalls.cpp.
References assert(), llvm::InstCombiner::Builder, C, llvm::InstCombiner::computeKnownBits(), llvm::APInt::countLeadingZeros(), llvm::APInt::countTrailingZeros(), llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::CallInst::getArgOperand(), llvm::InstCombiner::getDataLayout(), llvm::APInt::getHighBitsSet(), llvm::IntrinsicInst::getIntrinsicID(), llvm::APInt::getLowBitsSet(), llvm::IRBuilderBase::getTrue(), llvm::Value::getType(), llvm::isKnownNonZero(), IT(), llvm::PatternMatch::m_One(), llvm::BitmaskEnumDetail::Mask(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), 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 96 of file InstCombineCalls.cpp.
References assert(), E, llvm::ConstantInt::get(), llvm::ConstantVector::get(), llvm::Value::getContext(), llvm::ConstantDataSequential::getElementAsConstant(), llvm::ConstantDataSequential::getElementType(), llvm::Type::getInt1Ty(), llvm::ConstantDataSequential::getNumElements(), I, llvm::Type::isIntegerTy(), and llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back().
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 65 of file InstCombineCalls.cpp.
References llvm::Type::getContext(), and llvm::Type::getInt32Ty().
|
static |
Definition at line 1335 of file InstCombineCalls.cpp.
References assert(), llvm::CallInst::getArgOperand(), llvm::CallInst::getNumArgOperands(), and i.
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 2815 of file InstCombineCalls.cpp.
References llvm::User::getOperand(), llvm::Value::getType(), llvm::DataLayout::getTypeAllocSize(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::isByValOrInAllocaArgument(), llvm::isGCRelocate(), llvm::isGCResult(), llvm::CastInst::isLosslessCast(), llvm::Type::isSized(), and llvm::isStatepoint().
Definition at line 1143 of file InstCombineCalls.cpp.
References llvm::dyn_cast(), E, I, and llvm::BitmaskEnumDetail::Mask().
Referenced by simplifyMaskedLoad().
Given an aggregate type which ultimately holds a single scalar element, like {{{type}}} or [1 x type], return type.
Definition at line 75 of file InstCombineCalls.cpp.
References llvm::Type::isSingleValueType(), and T.
|
static |
Definition at line 1354 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 |
Definition at line 1191 of file InstCombineCalls.cpp.
References llvm::dyn_cast(), llvm::CallInst::getArgOperand(), and llvm::InstCombiner::replaceInstUsesWith().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 1159 of file InstCombineCalls.cpp.
References llvm::IRBuilder< T, Inserter >::CreateAlignedLoad(), llvm::CallInst::getArgOperand(), and maskIsAllOneOrUndef().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 1200 of file InstCombineCalls.cpp.
References llvm::dyn_cast(), llvm::InstCombiner::eraseInstFromFunction(), and llvm::CallInst::getArgOperand().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 1172 of file InstCombineCalls.cpp.
References llvm::dyn_cast(), llvm::InstCombiner::eraseInstFromFunction(), and llvm::CallInst::getArgOperand().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 1067 of file InstCombineCalls.cpp.
References assert(), llvm::dyn_cast(), llvm::CallInst::getArgOperand(), llvm::IntrinsicInst::getIntrinsicID(), llvm::PatternMatch::m_FMax(), llvm::PatternMatch::m_FMin(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::maxnum(), llvm::minnum(), X, and Y.
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 611 of file InstCombineCalls.cpp.
References AMDGPU::RuntimeMD::KeyName::Args, llvm::IRBuilder< T, Inserter >::CreateBitCast(), llvm::IRBuilder< T, Inserter >::CreateCall(), llvm::IRBuilder< T, Inserter >::CreateShuffleVector(), llvm::dyn_cast(), llvm::WebAssembly::End, F, llvm::ConstantInt::get(), llvm::ConstantAggregateZero::get(), llvm::VectorType::get(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::Constant::getAggregateElement(), llvm::Value::getContext(), llvm::Intrinsic::getDeclaration(), llvm::Type::getInt32Ty(), llvm::Type::getInt64Ty(), llvm::Type::getInt8Ty(), llvm::Constant::getIntegerValue(), llvm::IntrinsicInst::getIntrinsicID(), llvm::Instruction::getModule(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::APInt::getZExtValue(), i, llvm::APInt::lshr(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), and llvm::APInt::zextOrTrunc().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 255 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::CallInst::getArgOperand(), llvm::IntrinsicInst::getIntrinsicID(), i, llvm_unreachable, llvm::APInt::shl(), llvm::APInt::uge(), and llvm::APInt::zextOrTrunc().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 552 of file InstCombineCalls.cpp.
References assert(), llvm::IRBuilder< T, Inserter >::CreateShuffleVector(), llvm::dyn_cast(), llvm::ConstantAggregateZero::get(), llvm::CallInst::getArgOperand(), llvm::SequentialType::getNumElements(), llvm::Value::getType(), and i.
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 704 of file InstCombineCalls.cpp.
References AMDGPU::RuntimeMD::KeyName::Args, llvm::IRBuilder< T, Inserter >::CreateBitCast(), llvm::IRBuilder< T, Inserter >::CreateCall(), llvm::IRBuilder< T, Inserter >::CreateShuffleVector(), llvm::dyn_cast(), llvm::WebAssembly::End, F, llvm::ConstantInt::get(), llvm::VectorType::get(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::Constant::getAggregateElement(), llvm::Value::getContext(), llvm::Intrinsic::getDeclaration(), llvm::Type::getInt32Ty(), llvm::Type::getInt64Ty(), llvm::Type::getInt8Ty(), llvm::Constant::getIntegerValue(), llvm::IntrinsicInst::getIntrinsicID(), llvm::APInt::getLowBitsSet(), llvm::Instruction::getModule(), llvm::Value::getType(), llvm::APInt::getZExtValue(), i, llvm::BitmaskEnumDetail::Mask(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::APInt::shl(), and llvm::APInt::zextOrTrunc().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 1256 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(), Ptr, and llvm::InstCombiner::replaceInstUsesWith().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 1292 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 Ptr.
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Definition at line 513 of file InstCombineCalls.cpp.
References C, llvm::dyn_cast(), E, llvm::CallInst::getArgOperand(), llvm::Constant::getIntegerValue(), llvm::Constant::getNullValue(), llvm::Type::getPrimitiveSizeInBits(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), I, and llvm::Type::isVectorTy().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Attempt to convert pshufb* to shufflevector if the mask is constant.
Definition at line 799 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::CallInst::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 389 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::CallInst::getArgOperand(), llvm::IntrinsicInst::getIntrinsicID(), llvm::Constant::getNullValue(), llvm::Value::getType(), llvm::APInt::getZExtValue(), I, llvm_unreachable, llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), and llvm::APInt::uge().
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Decode XOP integer vector comparison intrinsics.
Definition at line 999 of file InstCombineCalls.cpp.
References llvm::CmpInst::BAD_ICMP_PREDICATE, llvm::IRBuilder< T, Inserter >::CreateICmp(), llvm::IRBuilder< T, Inserter >::CreateSExtOrTrunc(), llvm::CallInst::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 |
The shuffle mask for a perm2*128 selects any two halves of two 256-bit source vectors, unless a zero bit is set.
If a zero bit is set, then ignore that half of the mask and clear that half of the vector.
Definition at line 935 of file InstCombineCalls.cpp.
References llvm::IRBuilder< T, Inserter >::CreateShuffleVector(), llvm::dyn_cast(), llvm::ConstantAggregateZero::get(), llvm::CallInst::getArgOperand(), llvm::SequentialType::getNumElements(), llvm::Value::getType(), and i.
Referenced by llvm::InstCombiner::visitCallInst().
|
static |
Attempt to convert vpermilvar* to shufflevector if the mask is constant.
Definition at line 846 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::CallInst::getArgOperand(), llvm::Value::getContext(), llvm::Type::getInt32Ty(), llvm::APInt::getLoBits(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), I, llvm::APInt::lshr(), 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 896 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::CallInst::getArgOperand(), llvm::Value::getContext(), llvm::Type::getInt32Ty(), llvm::Value::getType(), I, llvm::makeArrayRef(), and llvm::NVPTX::PTXLdStInstCode::V2.
Referenced by llvm::InstCombiner::visitCallInst().
| STATISTIC | ( | NumSimplified | , |
| "Number of library calls simplified" | |||
| ) |
1.8.6