LLVM  mainline
Defines | Typedefs | Functions
InstCombineVectorOps.cpp File Reference
#include "InstCombineInternal.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/IR/PatternMatch.h"
Include dependency graph for InstCombineVectorOps.cpp:

Go to the source code of this file.

Defines

#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.

Functions

static bool CheapToScalarize (Value *V, bool isConstant)
 CheapToScalarize - Return true if the value is cheaper to scalarize than it is to leave as a vector operation.
static ValueFindScalarElement (Value *V, unsigned EltNo)
 FindScalarElement - Given a vector and an element number, see if the scalar value is already around as a register, for example if it were inserted then extracted from the vector.
static bool CollectSingleShuffleElements (Value *V, Value *LHS, Value *RHS, SmallVectorImpl< Constant * > &Mask)
 CollectSingleShuffleElements - If V is a shuffle of values that ONLY returns elements from either LHS or RHS, return the shuffle mask and true.
static ShuffleOps CollectShuffleElements (Value *V, SmallVectorImpl< Constant * > &Mask, Value *PermittedRHS)
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.
static ValueBuildNew (Instruction *I, ArrayRef< Value * > NewOps)
 Rebuild a new instruction just like 'I' but with the new operands given.
static void RecognizeIdentityMask (const SmallVectorImpl< int > &Mask, bool &isLHSID, bool &isRHSID)
static bool isShuffleExtractingFromLHS (ShuffleVectorInst &SVI, SmallVector< int, 16 > &Mask)

Define Documentation

#define DEBUG_TYPE   "instcombine"

Definition at line 21 of file InstCombineVectorOps.cpp.


Typedef Documentation

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 413 of file InstCombineVectorOps.cpp.


Function Documentation

static Value* BuildNew ( Instruction I,
ArrayRef< Value * >  NewOps 
) [static]
static bool CanEvaluateShuffled ( Value V,
ArrayRef< int Mask,
unsigned  Depth = 5 
) [static]
static bool CheapToScalarize ( Value V,
bool  isConstant 
) [static]

CheapToScalarize - 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 26 of file InstCombineVectorOps.cpp.

References llvm::C, llvm::dyn_cast(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::Value::hasOneUse(), I, llvm::InsertElement, and llvm::SPII::Load.

Referenced by llvm::InstCombiner::visitExtractElementInst().

static ShuffleOps CollectShuffleElements ( Value V,
SmallVectorImpl< Constant * > &  Mask,
Value PermittedRHS 
) [static]
static bool CollectSingleShuffleElements ( Value V,
Value LHS,
Value RHS,
SmallVectorImpl< Constant * > &  Mask 
) [static]

CollectSingleShuffleElements - 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 330 of file InstCombineVectorOps.cpp.

References 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, isPodLike< T >::value >::push_back().

Referenced by CollectShuffleElements().

static Value* FindScalarElement ( Value V,
unsigned  EltNo 
) [static]

FindScalarElement - Given a vector and an element number, see if the scalar value is already around as a register, for example if it were inserted then extracted from the vector.

Definition at line 66 of file InstCombineVectorOps.cpp.

References llvm::C, llvm::UndefValue::get(), llvm::Constant::getAggregateElement(), llvm::VectorType::getNumElements(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::Constant::isNullValue(), llvm::Type::isVectorTy(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Value(), and llvm::PatternMatch::match().

Referenced by llvm::InstCombiner::visitExtractElementInst().

static bool isShuffleExtractingFromLHS ( ShuffleVectorInst SVI,
SmallVector< int, 16 > &  Mask 
) [static]
static void RecognizeIdentityMask ( const SmallVectorImpl< int > &  Mask,
bool isLHSID,
bool isRHSID 
) [static]