LLVM
15.0.0git
|
#include "llvm/Transforms/Vectorize/VectorCombine.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/BasicAliasAnalysis.h"
#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/Loads.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 "llvm/Transforms/Utils/InstructionWorklist.h"
Go to the source code of this file.
Classes | |
class | ScalarizationResult |
Helper class to indicate whether a vector index can be safely scalarized and if a freeze needs to be inserted. More... | |
Macros | |
#define | DEBUG_TYPE "vector-combine" |
Functions | |
STATISTIC (NumVecLoad, "Number of vector loads formed") | |
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 Value * | createShiftShuffle (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 ExtractElementInst * | translateExtract (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... | |
static bool | isMemModifiedBetween (BasicBlock::iterator Begin, BasicBlock::iterator End, const MemoryLocation &Loc, AAResults &AA) |
static ScalarizationResult | canScalarizeAccess (FixedVectorType *VecTy, Value *Idx, Instruction *CtxI, AssumptionCache &AC, const DominatorTree &DT) |
Check if it is legal to scalarize a memory access to VecTy at index Idx . More... | |
static Align | computeAlignmentAfterScalarization (Align VectorAlignment, Type *ScalarType, Value *Idx, const DataLayout &DL) |
The memory operation on a vector of ScalarType had alignment of VectorAlignment . More... | |
INITIALIZE_PASS_BEGIN (VectorCombineLegacyPass, "vector-combine", "Optimize scalar/vector ops", false, false) INITIALIZE_PASS_END(VectorCombineLegacyPass | |
Variables | |
static cl::opt< bool > | DisableVectorCombine ("disable-vector-combine", cl::init(false), cl::Hidden, cl::desc("Disable all vector combine transforms")) |
static cl::opt< bool > | DisableBinopExtractShuffle ("disable-binop-extract-shuffle", cl::init(false), cl::Hidden, cl::desc("Disable binop extract to shuffle transforms")) |
static cl::opt< unsigned > | MaxInstrsToScan ("vector-combine-max-scan-instrs", cl::init(30), cl::Hidden, cl::desc("Max number of instructions to scan for vector combining.")) |
static const unsigned | InvalidIndex = std::numeric_limits<unsigned>::max() |
vector | combine |
vector Optimize scalar vector | ops |
vector Optimize scalar vector | false |
#define DEBUG_TYPE "vector-combine" |
Definition at line 34 of file VectorCombine.cpp.
|
static |
Check if it is legal to scalarize a memory access to VecTy
at index Idx
.
Idx
must access a valid vector element.
Definition at line 866 of file VectorCombine.cpp.
References llvm::ConstantRange::binaryAnd(), llvm::computeConstantRange(), llvm::ConstantRange::contains(), llvm::FixedVectorType::getNumElements(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::isGuaranteedNotToBePoison(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_URem(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), ScalarizationResult::safe(), ScalarizationResult::safeWithFreeze(), ScalarizationResult::unsafe(), and llvm::ConstantRange::urem().
|
static |
The memory operation on a vector of ScalarType
had alignment of VectorAlignment
.
Compute the maximal, but conservatively correct, alignment that will be valid for the memory operation on a single scalar element of the same type with index Idx
.
Definition at line 908 of file VectorCombine.cpp.
References llvm::commonAlignment(), and DL.
|
static |
Create a shuffle that translates (shifts) 1 element from the input vector to a new element location.
Definition at line 399 of file VectorCombine.cpp.
References Builder, llvm::Value::getType(), and llvm::UndefMaskElem.
Referenced by translateExtract().
INITIALIZE_PASS_BEGIN | ( | VectorCombineLegacyPass | , |
"vector-combine" | , | ||
"Optimize scalar/vector ops" | , | ||
false | , | ||
false | |||
) |
|
static |
Definition at line 799 of file VectorCombine.cpp.
STATISTIC | ( | NumScalarBO | , |
"Number of scalar binops formed" | |||
) |
STATISTIC | ( | NumScalarCmp | , |
"Number of scalar compares formed" | |||
) |
STATISTIC | ( | NumShufOfBitcast | , |
"Number of shuffles moved after bitcast" | |||
) |
STATISTIC | ( | NumVecBO | , |
"Number of vector binops formed" | |||
) |
STATISTIC | ( | NumVecCmp | , |
"Number of vector compares formed" | |||
) |
STATISTIC | ( | NumVecCmpBO | , |
"Number of vector compare + binop formed" | |||
) |
STATISTIC | ( | NumVecLoad | , |
"Number of vector loads formed" | |||
) |
|
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 414 of file VectorCombine.cpp.
References assert(), Builder, createShiftShuffle(), llvm::ExtractElementInst::getIndexOperand(), llvm::ExtractElementInst::getVectorOperand(), and X.
vector combine |
Definition at line 1548 of file VectorCombine.cpp.
|
static |
|
static |
vector Optimize scalar vector false |
Definition at line 1549 of file VectorCombine.cpp.
|
static |
Definition at line 60 of file VectorCombine.cpp.
|
static |
vector Optimize scalar vector ops |
Definition at line 1549 of file VectorCombine.cpp.