LLVM  6.0.0svn
Macros | Typedefs | Functions
InstCombineVectorOps.cpp File Reference
#include "InstCombineInternal.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/VectorUtils.h"
#include "llvm/IR/PatternMatch.h"
Include dependency graph for InstCombineVectorOps.cpp:

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 InstructionfoldInsSequenceIntoBroadcast (InsertElementInst &InsElt)
 
static InstructionhoistInsEltConst (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 InstructionfoldConstantInsEltIntoShuffle (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 ValuebuildNew (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)
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "instcombine"

Definition at line 23 of file InstCombineVectorOps.cpp.

Typedef Documentation

◆ ShuffleOps

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

Function Documentation

◆ buildNew()

static Value* buildNew ( Instruction I,
ArrayRef< Value *>  NewOps 
)
static

◆ CanEvaluateShuffled()

static bool CanEvaluateShuffled ( Value V,
ArrayRef< int >  Mask,
unsigned  Depth = 5 
)
static

◆ cheapToScalarize()

static bool cheapToScalarize ( Value V,
bool  isConstant 
)
static

◆ collectShuffleElements()

static ShuffleOps collectShuffleElements ( Value V,
SmallVectorImpl< Constant *> &  Mask,
Value PermittedRHS,
InstCombiner IC 
)
static

◆ collectSingleShuffleElements()

static bool collectSingleShuffleElements ( Value V,
Value LHS,
Value RHS,
SmallVectorImpl< Constant *> &  Mask 
)
static

◆ foldConstantInsEltIntoShuffle()

static Instruction* foldConstantInsEltIntoShuffle ( InsertElementInst InsElt)
static

◆ foldInsSequenceIntoBroadcast()

static Instruction* foldInsSequenceIntoBroadcast ( InsertElementInst InsElt)
static

◆ hoistInsEltConst()

static Instruction* hoistInsEltConst ( InsertElementInst InsElt2,
InstCombiner::BuilderTy Builder 
)
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 658 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().

◆ isShuffleEquivalentToSelect()

static bool isShuffleEquivalentToSelect ( ShuffleVectorInst Shuf)
static

◆ isShuffleExtractingFromLHS()

static bool isShuffleExtractingFromLHS ( ShuffleVectorInst SVI,
SmallVector< int, 16 > &  Mask 
)
static

◆ recognizeIdentityMask()

static void recognizeIdentityMask ( const SmallVectorImpl< int > &  Mask,
bool isLHSID,
bool isRHSID 
)
static

◆ replaceExtractElements()

static void replaceExtractElements ( InsertElementInst InsElt,
ExtractElementInst ExtElt,
InstCombiner IC 
)
static