|
LLVM
4.0.0
|
#include "InstCombineInternal.h"#include "llvm/ADT/DenseMap.h"#include "llvm/Analysis/InstructionSimplify.h"#include "llvm/Analysis/VectorUtils.h"#include "llvm/IR/PatternMatch.h"Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "instcombine" |
Typedefs | |
| typedef std::pair< Value *, Value * > | ShuffleOps |
| We are building a shuffle to create V, which is a sequence of insertelement, extractelement pairs. More... | |
Functions | |
| static bool | cheapToScalarize (Value *V, bool isConstant) |
| Return true if the value is cheaper to scalarize than it is to leave as a vector operation. More... | |
| static bool | collectSingleShuffleElements (Value *V, Value *LHS, Value *RHS, SmallVectorImpl< Constant * > &Mask) |
| If V is a shuffle of values that ONLY returns elements from either LHS or RHS, return the shuffle mask and true. More... | |
| static void | replaceExtractElements (InsertElementInst *InsElt, ExtractElementInst *ExtElt, InstCombiner &IC) |
| If we have insertion into a vector that is wider than the vector that we are extracting from, try to widen the source vector to allow a single shufflevector to replace one or more insert/extract pairs. More... | |
| static ShuffleOps | collectShuffleElements (Value *V, SmallVectorImpl< Constant * > &Mask, Value *PermittedRHS, InstCombiner &IC) |
| static bool | isShuffleEquivalentToSelect (ShuffleVectorInst &Shuf) |
| static Instruction * | foldInsSequenceIntoBroadcast (InsertElementInst &InsElt) |
| static Instruction * | foldConstantInsEltIntoShuffle (InsertElementInst &InsElt) |
| insertelt (shufflevector X, CVec, Mask|insertelt X, C1, CIndex1), C, CIndex –> shufflevector X, CVec', Mask' More... | |
| static bool | CanEvaluateShuffled (Value *V, ArrayRef< int > Mask, unsigned Depth=5) |
| Return true if we can evaluate the specified expression tree if the vector elements were shuffled in a different order. More... | |
| static Value * | buildNew (Instruction *I, ArrayRef< Value * > NewOps) |
| Rebuild a new instruction just like 'I' but with the new operands given. More... | |
| static void | recognizeIdentityMask (const SmallVectorImpl< int > &Mask, bool &isLHSID, bool &isRHSID) |
| static bool | isShuffleExtractingFromLHS (ShuffleVectorInst &SVI, SmallVector< int, 16 > &Mask) |
| #define DEBUG_TYPE "instcombine" |
Definition at line 23 of file InstCombineVectorOps.cpp.
| typedef std::pair<Value *, Value *> ShuffleOps |
We are building a shuffle to create V, which is a sequence of insertelement, extractelement pairs.
If PermittedRHS is set, then we must either use it or not rely on the second vector source. Return a std::pair containing the left and right vectors of the proposed shuffle (or 0), and set the Mask parameter as required.
Note: we intentionally don't try to fold earlier shuffles since they have often been chosen carefully to be efficiently implementable on the target.
Definition at line 456 of file InstCombineVectorOps.cpp.
|
static |
Rebuild a new instruction just like 'I' but with the new operands given.
In the event of type mismatch, the type of the operands is correct.
Definition at line 895 of file InstCombineVectorOps.cpp.
References llvm::MCID::Add, llvm::APIntOps::And(), assert(), llvm::BinaryOperator::Create(), llvm::CastInst::Create(), llvm::GetElementPtrInst::Create(), GEP, llvm::VectorType::get(), llvm::Instruction::getOpcode(), llvm::Type::getScalarType(), llvm::Value::getType(), llvm::Instruction::hasNoSignedWrap(), llvm::Instruction::hasNoUnsignedWrap(), I, llvm::Instruction::isExact(), llvm_unreachable, llvm::APIntOps::Or(), Ptr, llvm::GetElementPtrInst::setIsInBounds(), llvm::ArrayRef< T >::size(), llvm::ArrayRef< T >::slice(), and llvm::APIntOps::Xor().
Return true if we can evaluate the specified expression tree if the vector elements were shuffled in a different order.
Definition at line 819 of file InstCombineVectorOps.cpp.
References llvm::MCID::Add, llvm::APIntOps::And(), llvm::Depth, llvm::dyn_cast(), llvm::ConstantInt::getLimitedValue(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Value::hasOneUse(), I, i, llvm::BitmaskEnumDetail::Mask(), llvm::User::operands(), llvm::APIntOps::Or(), llvm::ArrayRef< T >::size(), and llvm::APIntOps::Xor().
Referenced by llvm::InstCombiner::visitShuffleVectorInst().
Return true if the value is cheaper to scalarize than it is to leave as a vector operation.
isConstant indicates whether we're extracting one known element. If false we're extracting a variable index.
Definition at line 28 of file InstCombineVectorOps.cpp.
References C, llvm::dyn_cast(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::Value::hasOneUse(), I, i, and llvm::SPII::Load.
Referenced by llvm::InstCombiner::visitExtractElementInst().
|
static |
Definition at line 458 of file InstCombineVectorOps.cpp.
References assert(), llvm::SmallVectorImpl< T >::assign(), collectSingleShuffleElements(), llvm::ConstantInt::get(), llvm::UndefValue::get(), llvm::Value::getContext(), llvm::Type::getInt32Ty(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), i, llvm::Type::isVectorTy(), llvm::BitmaskEnumDetail::Mask(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), and replaceExtractElements().
Referenced by llvm::InstCombiner::visitInsertElementInst().
|
static |
If V is a shuffle of values that ONLY returns elements from either LHS or RHS, return the shuffle mask and true.
Otherwise, return false.
Definition at line 297 of file InstCombineVectorOps.cpp.
References assert(), llvm::SmallVectorImpl< T >::assign(), llvm::ConstantInt::get(), llvm::UndefValue::get(), llvm::Value::getContext(), llvm::Type::getInt32Ty(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), i, and llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back().
Referenced by collectShuffleElements().
|
static |
insertelt (shufflevector X, CVec, Mask|insertelt X, C1, CIndex1), C, CIndex –> shufflevector X, CVec', Mask'
Definition at line 650 of file InstCombineVectorOps.cpp.
References assert(), llvm::sys::path::begin(), llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::Constant::getAggregateElement(), llvm::Value::getContext(), llvm::SequentialType::getElementType(), llvm::Type::getInt32Ty(), llvm::SequentialType::getNumElements(), llvm::User::getOperand(), llvm::Value::getType(), llvm::InsertElementInst::getType(), llvm::Type::getVectorNumElements(), I, Int32Ty, isShuffleEquivalentToSelect(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_ConstantInt(), llvm::BitmaskEnumDetail::Mask(), and llvm::PatternMatch::match().
Referenced by llvm::InstCombiner::visitInsertElementInst().
|
static |
Definition at line 600 of file InstCombineVectorOps.cpp.
References llvm::any_of(), llvm::InsertElementInst::Create(), llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::ConstantAggregateZero::get(), llvm::VectorType::get(), llvm::UndefValue::get(), llvm::Value::getContext(), llvm::Type::getInt32Ty(), llvm::SequentialType::getNumElements(), llvm::User::getOperand(), llvm::InsertElementInst::getType(), llvm::ConstantInt::getZExtValue(), llvm::Value::hasOneUse(), and llvm::Instruction::user_back().
Referenced by llvm::InstCombiner::visitInsertElementInst().
|
static |
Definition at line 577 of file InstCombineVectorOps.cpp.
References llvm::ShuffleVectorInst::getMask(), llvm::ShuffleVectorInst::getMaskValue(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), and i.
Referenced by foldConstantInsEltIntoShuffle().
|
static |
Definition at line 1090 of file InstCombineVectorOps.cpp.
References llvm::SmallVectorTemplateCommon< T >::back(), llvm::SmallVectorTemplateCommon< T >::front(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), I, and llvm::SmallVectorTemplateCommon< T >::size().
Referenced by llvm::InstCombiner::visitShuffleVectorInst().
|
static |
Definition at line 1070 of file InstCombineVectorOps.cpp.
References i, and llvm::SmallVectorTemplateCommon< T, typename >::size().
Referenced by llvm::InstCombiner::visitShuffleVectorInst().
|
static |
If we have insertion into a vector that is wider than the vector that we are extracting from, try to widen the source vector to allow a single shufflevector to replace one or more insert/extract pairs.
Definition at line 374 of file InstCombineVectorOps.cpp.
References llvm::ExtractElementInst::Create(), llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::Value::getContext(), llvm::SequentialType::getElementType(), llvm::BasicBlock::getFirstInsertionPt(), llvm::Type::getInt32Ty(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::InsertElementInst::getType(), llvm::Type::getVectorNumElements(), llvm::ExtractElementInst::getVectorOperand(), llvm::ExtractElementInst::getVectorOperandType(), llvm::Value::hasOneUse(), i, llvm::Instruction::insertAfter(), llvm::InstCombiner::InsertNewInstWith(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::InstCombiner::replaceInstUsesWith(), llvm::Instruction::user_back(), and llvm::Value::users().
Referenced by collectShuffleElements().
1.8.6