LLVM 24.0.0git
SLPMemoryUtils.h
Go to the documentation of this file.
1//===- SLPMemoryUtils.h - SLP pointer/stride helpers -----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Internal header used by SLPVectorizer.cpp. It declares free pointer and
10// stride helpers that do not depend on BoUpSLP or any other SLP-private type.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TRANSFORMS_VECTORIZE_SLPVECTORIZER_SLPMEMORYUTILS_H
15#define LLVM_LIB_TRANSFORMS_VECTORIZE_SLPVECTORIZER_SLPMEMORYUTILS_H
16
17#include "llvm/ADT/ArrayRef.h"
21
22namespace llvm {
23class AssumptionCache;
24class BasicBlock;
25class DataLayout;
26class DominatorTree;
27class FixedVectorType;
28class SCEV;
29class ScalarEvolution;
31class Type;
32class Value;
33class VectorType;
34} // namespace llvm
35
36namespace llvm::slpvectorizer {
37
38/// \p MaxDepth is the recursion limit for getUnderlyingObject.
39bool arePointersCompatible(Value *Ptr1, Value *Ptr2,
40 const TargetLibraryInfo &TLI, unsigned MaxDepth,
41 bool CompareOpcodes = true);
42
43/// Calculates minimal alignment as a common alignment.
44template <typename T> Align computeCommonAlignment(ArrayRef<Value *> VL);
45
46/// Checks if the provided list of pointers \p Pointers represents the strided
47/// pointers for type ElemTy. If they are not, nullptr is returned.
48/// Otherwise, SCEV* of the stride value is returned.
49/// If `PointerOps` can be rearranged into the following sequence:
50/// ```
51/// %x + c_0 * stride,
52/// %x + c_1 * stride,
53/// %x + c_2 * stride
54/// ...
55/// ```
56/// where each `c_i` is constant. The SCEV of the `stride` will be returned.
57const SCEV *calculateRtStride(ArrayRef<Value *> PointerOps, Type *ElemTy,
58 const DataLayout &DL, ScalarEvolution &SE,
59 SmallVectorImpl<unsigned> &SortedIndices);
60
61/// Checks if the \p VL can be transformed to a (masked)load + compress or
62/// (masked) interleaved load.
65 ArrayRef<unsigned> Order, const TargetTransformInfo &TTI,
66 const DataLayout &DL, ScalarEvolution &SE, AssumptionCache &AC,
67 const DominatorTree &DT, const TargetLibraryInfo &TLI,
69 const function_ref<bool(Value *)> AreAllUsersVectorized, bool ReVec,
70 bool &IsMasked, unsigned &InterleaveFactor,
71 SmallVectorImpl<int> &CompressMask, VectorType *&LoadVecTy);
72
73/// Checks if the \p VL can be transformed to a (masked)load + compress or
74/// (masked) interleaved load.
77 ArrayRef<unsigned> Order, const TargetTransformInfo &TTI,
78 const DataLayout &DL, ScalarEvolution &SE, AssumptionCache &AC,
79 const DominatorTree &DT, const TargetLibraryInfo &TLI,
81 const function_ref<bool(Value *)> AreAllUsersVectorized, bool ReVec);
82
83/// Checks if the stores \p VL with pointers \p PointerOps can be lowered as a
84/// single masked store. On success \p StoreVecTy is the widened store type and
85/// \p ReuseShuffleIndices is the expand mask that places each stored value at
86/// its element offset from the base (poison in the gaps).
88 ArrayRef<unsigned> Order,
89 const TargetTransformInfo &TTI, const DataLayout &DL,
90 ScalarEvolution &SE, Align CommonAlignment,
91 SmallVectorImpl<int> &ReuseShuffleIndices,
92 FixedVectorType *&StoreVecTy);
93
94/// Clusters \p VL pointers by (basic block, underlying object) pair and sorts
95/// each cluster by offset. Returns false and leaves \p SortedIndices empty if
96/// the accesses are not worth reordering.
98 Type *ElemTy, const DataLayout &DL,
99 ScalarEvolution &SE, unsigned MaxDepth,
100 SmallVectorImpl<unsigned> &SortedIndices);
101
102} // namespace llvm::slpvectorizer
103
104#endif // LLVM_LIB_TRANSFORMS_VECTORIZE_SLPVECTORIZER_SLPMEMORYUTILS_H
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static cl::opt< OutputCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(OutputCostKind::RecipThroughput), cl::values(clEnumValN(OutputCostKind::RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(OutputCostKind::Latency, "latency", "Instruction latency"), clEnumValN(OutputCostKind::CodeSize, "code-size", "Code size"), clEnumValN(OutputCostKind::SizeAndLatency, "size-latency", "Code size and latency"), clEnumValN(OutputCostKind::All, "all", "Print all cost kinds")))
This pass exposes codegen information to IR-level passes.
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
Definition BasicBlock.h:62
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition Dominators.h:122
Class to represent fixed width SIMD vectors.
This class represents an analyzed expression in the program.
The main scalar evolution driver.
Provides information about what library functions are available for the current target.
TargetCostKind
The kind of cost model.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
LLVM Value Representation.
Definition Value.h:75
Base class of all SIMD vector types.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
A private "module" namespace for types and utilities used by this pass.
Align computeCommonAlignment(ArrayRef< Value * > VL)
Calculates minimal alignment as a common alignment.
const SCEV * calculateRtStride(ArrayRef< Value * > PointerOps, Type *ElemTy, const DataLayout &DL, ScalarEvolution &SE, SmallVectorImpl< unsigned > &SortedIndices)
Checks if the provided list of pointers Pointers represents the strided pointers for type ElemTy.
bool isMaskedStoreCompress(ArrayRef< Value * > VL, ArrayRef< Value * > PointerOps, ArrayRef< unsigned > Order, const TargetTransformInfo &TTI, const DataLayout &DL, ScalarEvolution &SE, Align CommonAlignment, SmallVectorImpl< int > &ReuseShuffleIndices, FixedVectorType *&StoreVecTy)
Checks if the stores VL with pointers PointerOps can be lowered as a single masked store.
bool isMaskedLoadCompress(ArrayRef< Value * > VL, ArrayRef< Value * > PointerOps, ArrayRef< unsigned > Order, const TargetTransformInfo &TTI, const DataLayout &DL, ScalarEvolution &SE, AssumptionCache &AC, const DominatorTree &DT, const TargetLibraryInfo &TLI, const TargetTransformInfo::TargetCostKind CostKind, const function_ref< bool(Value *)> AreAllUsersVectorized, bool ReVec, bool &IsMasked, unsigned &InterleaveFactor, SmallVectorImpl< int > &CompressMask, VectorType *&LoadVecTy)
Checks if the VL can be transformed to a (masked)load + compress or (masked) interleaved load.
bool arePointersCompatible(Value *Ptr1, Value *Ptr2, const TargetLibraryInfo &TLI, unsigned MaxDepth, bool CompareOpcodes)
MaxDepth is the recursion limit for getUnderlyingObject.
bool clusterSortPtrAccesses(ArrayRef< Value * > VL, ArrayRef< BasicBlock * > BBs, Type *ElemTy, const DataLayout &DL, ScalarEvolution &SE, unsigned MaxDepth, SmallVectorImpl< unsigned > &SortedIndices)
Clusters VL pointers by (basic block, underlying object) pair and sorts each cluster by offset.
This is an optimization pass for GlobalISel generic memory operations.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
Definition InstrProf.h:143
TargetTransformInfo TTI
ArrayRef(const T &OneElt) -> ArrayRef< T >