LLVM 24.0.0git
SLPTypeUtils.h
Go to the documentation of this file.
1//===- SLPTypeUtils.h - SLP Vectorizer type/width 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 type and vector
10// width helpers that do not depend on BoUpSLP or any other SLP-private type.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TRANSFORMS_VECTORIZE_SLPVECTORIZER_SLPTYPEUTILS_H
15#define LLVM_LIB_TRANSFORMS_VECTORIZE_SLPVECTORIZER_SLPTYPEUTILS_H
16
17#include <limits>
18
19namespace llvm {
20class FixedVectorType;
22class Type;
23class Value;
24} // namespace llvm
25
26namespace llvm::slpvectorizer {
27
28/// Predicate for the element types that the SLP vectorizer supports.
29///
30/// The most important thing to filter here are types which are invalid in LLVM
31/// vectors. We also filter target specific types which have absolutely no
32/// meaningful vectorization path such as x86_fp80 and ppc_f128. This just
33/// avoids spending time checking the cost model and realizing that they will
34/// be inevitably scalarized.
35bool isValidElementType(Type *Ty, bool ReVec);
36
37/// Returns the "element type" of the given value/instruction \p V.
38/// For stores, returns the stored value type; for insertelement (when \p ReVec
39/// is off), the inserted operand type. For compares, the default is to return
40/// the result type (i1); when \p LookThroughCmp is true, returns the type of
41/// the compared operands instead, which is needed for vector width
42/// calculations (the width is determined by the operand type, not the i1
43/// result).
44Type *getValueType(Value *V, bool ReVec, bool LookThroughCmp = false);
45
46/// \returns the vector type of ScalarTy based on vectorization factor.
47Type *getWidenedType(Type *ScalarTy, unsigned VF);
48
49/// Returns the number of elements of the given type \p Ty, not less than \p Sz,
50/// which forms type, which splits by \p TTI into whole vector types during
51/// legalization.
52unsigned getFullVectorNumberOfElements(const TargetTransformInfo &TTI, Type *Ty,
53 unsigned Sz, bool ReVec);
54
55/// Returns the number of elements of the given type \p Ty, not greater than \p
56/// Sz, which forms type, which splits by \p TTI into whole vector types during
57/// legalization.
58unsigned getFloorFullVectorNumberOfElements(const TargetTransformInfo &TTI,
59 Type *Ty, unsigned Sz, bool ReVec);
60
61/// For a non-power-of-2 \p NumElts-wide integer div/rem \p Opcode, returns the
62/// padded full-register vector type if padding is structurally possible, or
63/// nullptr if the vector already fills a register or the opcode is not
64/// div/rem. Does not check profitability.
65FixedVectorType *getMaskedDivRemType(const TargetTransformInfo &TTI,
66 unsigned Opcode, Type *ScalarTy,
67 unsigned NumElts, bool ReVec);
68
69/// Returns true if widened type of \p Ty elements with size \p Sz represents
70/// full vector type, i.e. adding extra element results in extra parts upon type
71/// legalization.
72bool hasFullVectorsOrPowerOf2(const TargetTransformInfo &TTI, Type *Ty,
73 unsigned Sz, bool ReVec);
74
75/// True when \p AllowNonPowerOf2 is set and \p NumElts is a supported
76/// non-power-of-2 width: \p NumElts + 1 must be a power of two (e.g. 3 or 7
77/// lanes, i.e. almost a full power-of-2 register).
78bool isAllowedNonPowerOf2VF(unsigned NumElts, bool AllowNonPowerOf2);
79
80/// Returns number of parts, the type \p VecTy will be split at the codegen
81/// phase. If the type is going to be scalarized or does not use whole
82/// registers, returns 1.
83unsigned
84getNumberOfParts(const TargetTransformInfo &TTI, Type *VecTy, Type *ScalarTy,
85 bool ReVec,
86 unsigned Limit = std::numeric_limits<unsigned>::max());
87
88} // namespace llvm::slpvectorizer
89
90#endif // LLVM_LIB_TRANSFORMS_VECTORIZE_SLPVECTORIZER_SLPTYPEUTILS_H
Class to represent fixed width SIMD vectors.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
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
A private "module" namespace for types and utilities used by this pass.
unsigned getFloorFullVectorNumberOfElements(const TargetTransformInfo &TTI, Type *Ty, unsigned Sz, bool ReVec)
Returns the number of elements of the given type Ty, not greater than Sz, which forms type,...
Type * getWidenedType(Type *ScalarTy, unsigned VF)
unsigned getNumberOfParts(const TargetTransformInfo &TTI, Type *VecTy, Type *ScalarTy, bool ReVec, unsigned Limit)
Returns number of parts, the type VecTy will be split at the codegen phase.
bool hasFullVectorsOrPowerOf2(const TargetTransformInfo &TTI, Type *Ty, unsigned Sz, bool ReVec)
Returns true if widened type of Ty elements with size Sz represents full vector type,...
bool isAllowedNonPowerOf2VF(unsigned NumElts, bool AllowNonPowerOf2)
True when AllowNonPowerOf2 is set and NumElts is a supported non-power-of-2 width: NumElts + 1 must b...
FixedVectorType * getMaskedDivRemType(const TargetTransformInfo &TTI, unsigned Opcode, Type *ScalarTy, unsigned NumElts, bool ReVec)
For a non-power-of-2 NumElts-wide integer div/rem Opcode, returns the padded full-register vector typ...
bool isValidElementType(Type *Ty, bool ReVec)
Predicate for the element types that the SLP vectorizer supports.
Type * getValueType(Value *V, bool ReVec, bool LookThroughCmp)
Returns the "element type" of the given value/instruction V.
unsigned getFullVectorNumberOfElements(const TargetTransformInfo &TTI, Type *Ty, unsigned Sz, bool ReVec)
Returns the number of elements of the given type Ty, not less than Sz, which forms type,...
This is an optimization pass for GlobalISel generic memory operations.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
Definition InstrProf.h:143
TargetTransformInfo TTI