LLVM  11.0.0git
Classes | Macros | Functions | Variables
VectorCombine.cpp File Reference
#include "llvm/Transforms/Vectorize/VectorCombine.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/BasicAliasAnalysis.h"
#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/Analysis/VectorUtils.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Vectorize.h"
Include dependency graph for VectorCombine.cpp:

Go to the source code of this file.

Classes

class  VectorCombine
 

Macros

#define DEBUG_TYPE   "vector-combine"
 

Functions

 STATISTIC (NumVecCmp, "Number of vector compares formed")
 
 STATISTIC (NumVecBO, "Number of vector binops formed")
 
 STATISTIC (NumVecCmpBO, "Number of vector compare + binop formed")
 
 STATISTIC (NumShufOfBitcast, "Number of shuffles moved after bitcast")
 
 STATISTIC (NumScalarBO, "Number of scalar binops formed")
 
 STATISTIC (NumScalarCmp, "Number of scalar compares formed")
 
static void replaceValue (Value &Old, Value &New)
 
static ValuecreateShiftShuffle (Value *Vec, unsigned OldIndex, unsigned NewIndex, IRBuilder<> &Builder)
 Create a shuffle that translates (shifts) 1 element from the input vector to a new element location. More...
 
static ExtractElementInsttranslateExtract (ExtractElementInst *ExtElt, unsigned NewIndex, IRBuilder<> &Builder)
 Given an extract element instruction with constant index operand, shuffle the source vector (shift the scalar element) to a NewIndex for extraction. More...
 
 INITIALIZE_PASS_BEGIN (VectorCombineLegacyPass, "vector-combine", "Optimize scalar/vector ops", false, false) INITIALIZE_PASS_END(VectorCombineLegacyPass
 

Variables

static cl::opt< boolDisableVectorCombine ("disable-vector-combine", cl::init(false), cl::Hidden, cl::desc("Disable all vector combine transforms"))
 
static cl::opt< boolDisableBinopExtractShuffle ("disable-binop-extract-shuffle", cl::init(false), cl::Hidden, cl::desc("Disable binop extract to shuffle transforms"))
 
static const unsigned InvalidIndex = std::numeric_limits<unsigned>::max()
 
vector combine
 
vector Optimize scalar vector ops
 
vector Optimize scalar vector false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "vector-combine"

Definition at line 35 of file VectorCombine.cpp.

Function Documentation

◆ createShiftShuffle()

static Value* createShiftShuffle ( Value Vec,
unsigned  OldIndex,
unsigned  NewIndex,
IRBuilder<> &  Builder 
)
static

Create a shuffle that translates (shifts) 1 element from the input vector to a new element location.

Definition at line 224 of file VectorCombine.cpp.

References llvm::IRBuilderBase::CreateShuffleVector(), llvm::UndefValue::get(), llvm::Value::getType(), llvm::RegState::Undef, and llvm::UndefMaskElem.

Referenced by translateExtract().

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( VectorCombineLegacyPass  ,
"vector-combine ,
"Optimize scalar/vector ops ,
false  ,
false   
)

Referenced by VectorCombine::run().

◆ replaceValue()

static void replaceValue ( Value Old,
Value New 
)
static

◆ STATISTIC() [1/6]

STATISTIC ( NumVecCmp  ,
"Number of vector compares formed"   
)

◆ STATISTIC() [2/6]

STATISTIC ( NumVecBO  ,
"Number of vector binops formed"   
)

◆ STATISTIC() [3/6]

STATISTIC ( NumVecCmpBO  ,
"Number of vector compare + binop formed"   
)

◆ STATISTIC() [4/6]

STATISTIC ( NumShufOfBitcast  ,
"Number of shuffles moved after bitcast"   
)

◆ STATISTIC() [5/6]

STATISTIC ( NumScalarBO  ,
"Number of scalar binops formed"   
)

◆ STATISTIC() [6/6]

STATISTIC ( NumScalarCmp  ,
"Number of scalar compares formed"   
)

◆ translateExtract()

static ExtractElementInst* translateExtract ( ExtractElementInst ExtElt,
unsigned  NewIndex,
IRBuilder<> &  Builder 
)
static

Given an extract element instruction with constant index operand, shuffle the source vector (shift the scalar element) to a NewIndex for extraction.

Return null if the input can be constant folded, so that we are not creating unnecessary instructions.

Definition at line 240 of file VectorCombine.cpp.

References assert(), llvm::CmpInst::BAD_ICMP_PREDICATE, Builder, C, llvm::IRBuilderBase::CreateExtractElement(), createShiftShuffle(), llvm::dyn_cast(), llvm::ConstantVector::get(), llvm::ConstantExpr::get(), llvm::UndefValue::get(), llvm::TargetTransformInfo::getArithmeticInstrCost(), llvm::TargetTransformInfo::getCmpSelInstrCost(), llvm::ConstantExpr::getCompare(), llvm::ConstantExpr::getExtractElement(), llvm::ExtractElementInst::getIndexOperand(), llvm::Value::getName(), llvm::VectorType::getNumElements(), llvm::Instruction::getOpcode(), getOpcode(), llvm::User::getOperand(), llvm::PPC::getPredicate(), llvm::TargetTransformInfo::getShuffleCost(), llvm::Value::getType(), llvm::TargetTransformInfo::getVectorInstrCost(), llvm::ExtractElementInst::getVectorOperand(), llvm::Value::hasOneUse(), I, InvalidIndex, llvm::Instruction::isBinaryOp(), llvm::Type::isFloatingPointTy(), llvm::CmpInst::isFPPredicate(), llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), llvm::isSafeToSpeculativelyExecute(), llvm::Type::isVectorTy(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_BitCast(), llvm::PatternMatch::m_Cmp(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_ExtractElt(), llvm::PatternMatch::m_InsertElt(), llvm::PatternMatch::m_Instruction(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_Shuffle(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::CmpInst::makeCmpResultType(), llvm::BitmaskEnumDetail::Mask(), llvm::PatternMatch::match(), llvm::narrowShuffleMaskElts(), replaceValue(), llvm::NVPTX::PTXLdStInstCode::Scalar, llvm::TargetTransformInfo::SK_PermuteSingleSrc, llvm::Instruction::user_back(), llvm::Value::users(), llvm::widenShuffleMaskElts(), and X.

Variable Documentation

◆ combine

vector combine

◆ DisableBinopExtractShuffle

cl::opt<bool> DisableBinopExtractShuffle("disable-binop-extract-shuffle", cl::init(false), cl::Hidden, cl::desc("Disable binop extract to shuffle transforms"))
static

Referenced by replaceValue().

◆ DisableVectorCombine

cl::opt<bool> DisableVectorCombine("disable-vector-combine", cl::init(false), cl::Hidden, cl::desc("Disable all vector combine transforms"))
static

Referenced by VectorCombine::run().

◆ false

vector Optimize scalar vector false

Definition at line 678 of file VectorCombine.cpp.

◆ InvalidIndex

const unsigned InvalidIndex = std::numeric_limits<unsigned>::max()
static

Definition at line 51 of file VectorCombine.cpp.

Referenced by isInSymtab(), and translateExtract().

◆ ops

vector Optimize scalar vector ops

Definition at line 678 of file VectorCombine.cpp.