|
LLVM
10.0.0
|
#include "InstCombineInternal.h"#include "llvm/ADT/APInt.h"#include "llvm/ADT/ArrayRef.h"#include "llvm/ADT/DenseMap.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/SmallVector.h"#include "llvm/Analysis/InstructionSimplify.h"#include "llvm/Analysis/VectorUtils.h"#include "llvm/IR/BasicBlock.h"#include "llvm/IR/Constant.h"#include "llvm/IR/Constants.h"#include "llvm/IR/DerivedTypes.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/User.h"#include "llvm/IR/Value.h"#include "llvm/Support/Casting.h"#include "llvm/Support/ErrorHandling.h"#include "llvm/Transforms/InstCombine/InstCombineWorklist.h"#include <cassert>#include <cstdint>#include <iterator>#include <utility>Go to the source code of this file.
Classes | |
| struct | BinopElts |
| These are the ingredients in an alternate form binary operator as described below. More... | |
Macros | |
| #define | DEBUG_TYPE "instcombine" |
Typedefs | |
| using | ShuffleOps = std::pair< Value *, Value * > |
| We are building a shuffle to create V, which is a sequence of insertelement, extractelement pairs. More... | |
Functions | |
| static bool | cheapToScalarize (Value *V, bool IsConstantExtractIndex) |
| Return true if the value is cheaper to scalarize than it is to leave as a vector operation. More... | |
| static Instruction * | foldBitcastExtElt (ExtractElementInst &Ext, InstCombiner::BuilderTy &Builder, bool IsBigEndian) |
| static APInt | findDemandedEltsBySingleUser (Value *V, Instruction *UserInstr) |
| Find elements of V demanded by UserInstr. More... | |
| static APInt | findDemandedEltsByAllUsers (Value *V) |
| Find union of elements of V demanded by all its users. 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 * | foldInsSequenceIntoSplat (InsertElementInst &InsElt) |
| Turn a chain of inserts that splats a value into an insert + shuffle: insertelt(insertelt(insertelt(insertelt X, k, 0), k, 1), k, 2) ... More... | |
| static Instruction * | foldInsEltIntoSplat (InsertElementInst &InsElt) |
| Try to fold an insert element into an existing splat shuffle by changing the shuffle's mask to include the index of this insert element. More... | |
| static Instruction * | foldInsEltIntoIdentityShuffle (InsertElementInst &InsElt) |
| Try to fold an extract+insert element into an existing identity shuffle by changing the shuffle's mask to include the index of this insert element. More... | |
| static Instruction * | hoistInsEltConst (InsertElementInst &InsElt2, InstCombiner::BuilderTy &Builder) |
| If we have an insertelement instruction feeding into another insertelement and the 2nd is inserting a constant into the vector, canonicalize that constant insertion before the insertion of a variable: More... | |
| 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 Value * | evaluateInDifferentElementOrder (Value *V, ArrayRef< int > Mask) |
| static bool | isShuffleExtractingFromLHS (ShuffleVectorInst &SVI, SmallVector< int, 16 > &Mask) |
| static BinopElts | getAlternateBinop (BinaryOperator *BO, const DataLayout &DL) |
| Binops may be transformed into binops with different opcodes and operands. More... | |
| static Instruction * | foldSelectShuffleWith1Binop (ShuffleVectorInst &Shuf) |
| static Instruction * | canonicalizeInsertSplat (ShuffleVectorInst &Shuf, InstCombiner::BuilderTy &Builder) |
| If we have an insert of a scalar to a non-zero element of an undefined vector and then shuffle that value, that's the same as inserting to the zero element and shuffling. More... | |
| static Instruction * | foldSelectShuffle (ShuffleVectorInst &Shuf, InstCombiner::BuilderTy &Builder, const DataLayout &DL) |
| Try to fold shuffles that are the equivalent of a vector select. More... | |
| static Instruction * | narrowVectorSelect (ShuffleVectorInst &Shuf, InstCombiner::BuilderTy &Builder) |
| Match a shuffle-select-shuffle pattern where the shuffles are widening and narrowing (concatenating with undef and extracting back to the original length). More... | |
| static Instruction * | foldIdentityExtractShuffle (ShuffleVectorInst &Shuf) |
| Try to combine 2 shuffles into 1 shuffle by concatenating a shuffle mask. More... | |
| static Instruction * | foldShuffleWithInsert (ShuffleVectorInst &Shuf) |
| Try to replace a shuffle with an insertelement or try to replace a shuffle operand with the operand of an insertelement. More... | |
| static Instruction * | foldIdentityPaddedShuffles (ShuffleVectorInst &Shuf) |
| #define DEBUG_TYPE "instcombine" |
Definition at line 45 of file InstCombineVectorOps.cpp.
| using ShuffleOps = std::pair<Value *, Value *> |
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 604 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 1213 of file InstCombineVectorOps.cpp.
References llvm::MCID::Add, assert(), llvm::BinaryOperator::Create(), llvm::CastInst::Create(), llvm::GetElementPtrInst::Create(), GEP, llvm::VectorType::get(), llvm::Instruction::getOpcode(), getOpcode(), llvm::PPC::getPredicate(), llvm::Type::getScalarType(), llvm::Value::getType(), llvm::Instruction::hasNoSignedWrap(), llvm::Instruction::hasNoUnsignedWrap(), I, llvm::Instruction::isExact(), llvm_unreachable, llvm::GetElementPtrInst::setIsInBounds(), llvm::ArrayRef< T >::size(), and llvm::ArrayRef< T >::slice().
Referenced by evaluateInDifferentElementOrder().
Return true if we can evaluate the specified expression tree if the vector elements were shuffled in a different order.
Definition at line 1126 of file InstCombineVectorOps.cpp.
References llvm::MCID::Add, llvm::any_of(), llvm::Depth, llvm::dyn_cast(), llvm::numbers::e, llvm::ConstantInt::getLimitedValue(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::Value::hasOneUse(), I, llvm::Type::isVectorTy(), LLVM_FALLTHROUGH, llvm::BitmaskEnumDetail::Mask(), llvm::User::operands(), and llvm::ArrayRef< T >::size().
Referenced by llvm::InstCombiner::visitShuffleVectorInst().
|
static |
If we have an insert of a scalar to a non-zero element of an undefined vector and then shuffle that value, that's the same as inserting to the zero element and shuffling.
Splatting from the zero element is recognized as the canonical form of splat.
Definition at line 1511 of file InstCombineVectorOps.cpp.
References llvm::IRBuilder< T, Inserter >::CreateInsertElement(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::Constant::getAggregateElement(), llvm::IRBuilderBase::getInt32(), llvm::ShuffleVectorInst::getMask(), llvm::User::getOperand(), llvm::ShuffleVectorInst::getType(), llvm::Type::getVectorNumElements(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_InsertElement(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZeroInt(), llvm::BitmaskEnumDetail::Mask(), llvm::PatternMatch::match(), and X.
Referenced by llvm::InstCombiner::visitShuffleVectorInst().
Return true if the value is cheaper to scalarize than it is to leave as a vector operation.
IsConstantExtractIndex indicates whether we are extracting one known element from a vector constant.
FIXME: It's possible to create more instructions than previously existed.
Definition at line 52 of file InstCombineVectorOps.cpp.
References llvm::PHINode::addIncoming(), C, llvm::ExtractElementInst::Create(), llvm::PHINode::Create(), llvm::BinaryOperator::CreateWithCopiedFlags(), llvm::dyn_cast(), E, llvm::BasicBlock::getFirstInsertionPt(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::ExtractElementInst::getIndexOperand(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Value::getName(), llvm::PHINode::getNumIncomingValues(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Value::hasOneUse(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_Cmp(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_InsertElement(), llvm::PatternMatch::m_Load(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::Instruction::user_back(), and llvm::Value::users().
Referenced by llvm::InstCombiner::visitExtractElementInst().
|
static |
Definition at line 606 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(), llvm::Type::isVectorTy(), llvm::BitmaskEnumDetail::Mask(), llvm::SmallVectorTemplateBase< T >::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 445 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(), and llvm::SmallVectorTemplateBase< T >::push_back().
Referenced by collectShuffleElements().
Definition at line 1289 of file InstCombineVectorOps.cpp.
References llvm::MCID::Add, assert(), buildNew(), C, llvm::InsertElementInst::Create(), llvm::numbers::e, llvm::ConstantInt::get(), llvm::ConstantAggregateZero::get(), llvm::VectorType::get(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::Value::getContext(), llvm::Type::getInt32Ty(), llvm::Type::getScalarType(), llvm::ConstantExpr::getShuffleVector(), llvm::Value::getType(), I, llvm::Type::isVectorTy(), llvm_unreachable, llvm::BitmaskEnumDetail::Mask(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::MCID::Select, and llvm::ArrayRef< T >::size().
Referenced by llvm::InstCombiner::visitShuffleVectorInst().
Find union of elements of V demanded by all its users.
If it is known by querying findDemandedEltsBySingleUser that no user demands an element of V, then the corresponding bit remains unset in the returned value.
Definition at line 300 of file InstCombineVectorOps.cpp.
References findDemandedEltsBySingleUser(), llvm::APInt::getAllOnesValue(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), I, llvm::APInt::isAllOnesValue(), and llvm::Value::uses().
Referenced by llvm::InstCombiner::visitExtractElementInst().
|
static |
Find elements of V demanded by UserInstr.
Definition at line 257 of file InstCombineVectorOps.cpp.
References assert(), llvm::dyn_cast(), llvm::APInt::getAllOnesValue(), llvm::ExtractElementInst::getIndexOperand(), llvm::ShuffleVectorInst::getMaskValue(), llvm::APInt::getOneBitSet(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::ExtractElementInst::getVectorOperand(), and llvm::APInt::setBit().
Referenced by findDemandedEltsByAllUsers().
|
static |
Definition at line 162 of file InstCombineVectorOps.cpp.
References llvm::IRBuilder< T, Inserter >::CreateBitCast(), llvm::IRBuilder< T, Inserter >::CreateLShr(), llvm::IRBuilder< T, Inserter >::CreateTrunc(), llvm::findScalarElement(), llvm::Value::getContext(), llvm::ExtractElementInst::getIndexOperand(), llvm::Type::getIntNTy(), llvm::SequentialType::getNumElements(), llvm::Type::getPrimitiveSizeInBits(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::ExtractElementInst::getVectorOperand(), llvm::ExtractElementInst::getVectorOperandType(), llvm::Value::hasOneUse(), llvm::Type::isFloatingPointTy(), llvm::Type::isVectorTy(), llvm::PatternMatch::m_BitCast(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_InsertElement(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::NVPTX::PTXLdStInstCode::Scalar, and X.
Referenced by llvm::InstCombiner::visitExtractElementInst().
|
static |
insertelt (shufflevector X, CVec, Mask|insertelt X, C1, CIndex1), C, CIndex –> shufflevector X, CVec', Mask'
Definition at line 929 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 |
Try to combine 2 shuffles into 1 shuffle by concatenating a shuffle mask.
Definition at line 1705 of file InstCombineVectorOps.cpp.
References assert(), llvm::ConstantVector::get(), llvm::Constant::getAggregateElement(), llvm::ShuffleVectorInst::getMask(), llvm::User::getOperand(), getType(), llvm::ShuffleVectorInst::getType(), llvm::Type::getVectorNumElements(), llvm::Value::hasOneUse(), llvm::ShuffleVectorInst::isIdentityWithExtract(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_ShuffleVector(), llvm::PatternMatch::m_Value(), llvm::BitmaskEnumDetail::Mask(), llvm::PatternMatch::match(), X, and Y.
Referenced by llvm::InstCombiner::visitShuffleVectorInst().
|
static |
Definition at line 1835 of file InstCombineVectorOps.cpp.
References assert(), llvm::dyn_cast(), llvm::numbers::e, llvm::ConstantInt::get(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::Value::getContext(), llvm::Type::getInt32Ty(), llvm::User::getOperand(), llvm::ShuffleVectorInst::getShuffleMask(), llvm::Value::getType(), llvm::ShuffleVectorInst::getType(), llvm::Type::getVectorNumElements(), llvm::isPowerOf2_32(), llvm::BitmaskEnumDetail::Mask(), X, and Y.
Referenced by llvm::InstCombiner::visitShuffleVectorInst().
|
static |
Try to fold an extract+insert element into an existing identity shuffle by changing the shuffle's mask to include the index of this insert element.
Definition at line 850 of file InstCombineVectorOps.cpp.
References assert(), llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::ConstantVector::get(), llvm::Constant::getAggregateElement(), llvm::Type::getInt32Ty(), llvm::User::getOperand(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_ExtractElement(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::match(), llvm::NVPTX::PTXLdStInstCode::Scalar, and X.
Referenced by llvm::InstCombiner::visitInsertElementInst().
|
static |
Try to fold an insert element into an existing splat shuffle by changing the shuffle's mask to include the index of this insert element.
Definition at line 816 of file InstCombineVectorOps.cpp.
References llvm::dyn_cast(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::Type::getInt32Ty(), llvm::Constant::getNullValue(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_InsertElement(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_ZeroInt(), llvm::PatternMatch::match(), and X.
Referenced by llvm::InstCombiner::visitInsertElementInst().
|
static |
Turn a chain of inserts that splats a value into an insert + shuffle: insertelt(insertelt(insertelt(insertelt X, k, 0), k, 1), k, 2) ...
-> shufflevector(insertelt(X, k, 0), undef, zero)
Definition at line 747 of file InstCombineVectorOps.cpp.
References llvm::any_of(), llvm::InsertElementInst::Create(), llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::Value::getContext(), llvm::Type::getInt32Ty(), llvm::User::getOperand(), llvm::InsertElementInst::getType(), llvm::Value::hasOneUse(), Int32Ty, isZero(), llvm::BitmaskEnumDetail::Mask(), and llvm::Instruction::user_back().
Referenced by llvm::InstCombiner::visitInsertElementInst().
|
static |
Try to fold shuffles that are the equivalent of a vector select.
Definition at line 1543 of file InstCombineVectorOps.cpp.
References llvm::Instruction::andIRFlags(), assert(), llvm::ShuffleVectorInst::commute(), llvm::Constant::containsUndefElement(), llvm::Instruction::copyIRFlags(), llvm::BinaryOperator::Create(), llvm::IRBuilder< T, Inserter >::CreateShuffleVector(), llvm::Instruction::dropPoisonGeneratingFlags(), foldSelectShuffleWith1Binop(), getAlternateBinop(), llvm::ShuffleVectorInst::getMask(), llvm::ShuffleVectorInst::getMaskValue(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::getSafeVectorConstantForBinop(), llvm::ConstantExpr::getShuffleVector(), llvm::ShuffleVectorInst::getType(), llvm::Type::getVectorNumElements(), llvm::Value::hasOneUse(), I, llvm::Instruction::isIntDivRem(), llvm::ShuffleVectorInst::isSelect(), llvm::Instruction::isShift(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Value(), llvm::BitmaskEnumDetail::Mask(), llvm::PatternMatch::match(), llvm::Instruction::setHasNoSignedWrap(), X, and Y.
Referenced by llvm::InstCombiner::visitShuffleVectorInst().
|
static |
Definition at line 1455 of file InstCombineVectorOps.cpp.
References assert(), C, llvm::Constant::containsUndefElement(), llvm::Instruction::copyIRFlags(), llvm::BinaryOperator::Create(), llvm::Instruction::dropPoisonGeneratingFlags(), llvm::ConstantExpr::getBinOpIdentity(), llvm::ShuffleVectorInst::getMask(), llvm::User::getOperand(), llvm::getSafeVectorConstantForBinop(), llvm::ConstantExpr::getShuffleVector(), llvm::ShuffleVectorInst::getType(), llvm::Instruction::isIntDivRem(), llvm::ShuffleVectorInst::isSelect(), llvm::Instruction::isShift(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Specific(), llvm::BitmaskEnumDetail::Mask(), llvm::PatternMatch::match(), and X.
Referenced by foldSelectShuffle().
|
static |
Try to replace a shuffle with an insertelement or try to replace a shuffle operand with the operand of an insertelement.
Definition at line 1746 of file InstCombineVectorOps.cpp.
References assert(), llvm::ShuffleVectorInst::commuteShuffleMask(), llvm::InsertElementInst::Create(), llvm::ConstantInt::get(), llvm::User::getOperand(), llvm::ShuffleVectorInst::getShuffleMask(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_InsertElement(), llvm::PatternMatch::m_Value(), llvm::BitmaskEnumDetail::Mask(), llvm::PatternMatch::match(), llvm::none_of(), llvm::NVPTX::PTXLdStInstCode::Scalar, llvm::User::setOperand(), llvm::SmallVectorBase::size(), std::swap(), and X.
Referenced by llvm::InstCombiner::visitShuffleVectorInst().
|
static |
Binops may be transformed into binops with different opcodes and operands.
Reverse the usual canonicalization to enable folds with the non-canonical form of the binop. If a transform is possible, return the elements of the new binop. If not, return invalid elements.
Definition at line 1429 of file InstCombineVectorOps.cpp.
References llvm::MCID::Add, C, llvm::ConstantInt::get(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::ConstantExpr::getShl(), llvm::Value::getType(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_Constant(), llvm::MaskedValueIsZero(), and llvm::PatternMatch::match().
Referenced by foldSelectShuffle().
|
static |
If we have an insertelement instruction feeding into another insertelement and the 2nd is inserting a constant into the vector, canonicalize that constant insertion before the insertion of a variable:
insertelement (insertelement X, Y, IdxC1), ScalarC, IdxC2 –> insertelement (insertelement X, ScalarC, IdxC2), Y, IdxC1
This has the potential of eliminating the 2nd insertelement instruction via constant folding of the scalar constant into a vector constant.
Definition at line 906 of file InstCombineVectorOps.cpp.
References llvm::InsertElementInst::Create(), llvm::IRBuilder< T, Inserter >::CreateInsertElement(), llvm::dyn_cast(), llvm::User::getOperand(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), X, and Y.
Referenced by llvm::InstCombiner::visitInsertElementInst().
|
static |
Definition at line 725 of file InstCombineVectorOps.cpp.
References llvm::ShuffleVectorInst::getMask(), llvm::ShuffleVectorInst::getMaskValue(), llvm::User::getOperand(), llvm::Value::getType(), and llvm::Type::getVectorNumElements().
Referenced by foldConstantInsEltIntoShuffle().
|
static |
Definition at line 1399 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::SmallVectorBase::size().
Referenced by llvm::InstCombiner::visitShuffleVectorInst().
|
static |
Match a shuffle-select-shuffle pattern where the shuffles are widening and narrowing (concatenating with undef and extracting back to the original length).
This allows replacing the wide select with a narrow select.
Definition at line 1672 of file InstCombineVectorOps.cpp.
References llvm::User::getOperand(), llvm::ShuffleVectorInst::isIdentityWithExtract(), llvm::PatternMatch::m_Undef(), and llvm::PatternMatch::match().
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 522 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(), llvm::Instruction::insertAfter(), llvm::InstCombiner::InsertNewInstWith(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::InstCombiner::replaceInstUsesWith(), llvm::Instruction::user_back(), and llvm::Value::users().
Referenced by collectShuffleElements().
1.8.13