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
17namespace llvm {
18class FixedVectorType;
20class Type;
21class Value;
22} // namespace llvm
23
24namespace llvm::slpvectorizer {
25
26/// Predicate for the element types that the SLP vectorizer supports.
27///
28/// The most important thing to filter here are types which are invalid in LLVM
29/// vectors. We also filter target specific types which have absolutely no
30/// meaningful vectorization path such as x86_fp80 and ppc_f128. This just
31/// avoids spending time checking the cost model and realizing that they will
32/// be inevitably scalarized.
33bool isValidElementType(Type *Ty, bool ReVec);
34
35/// Returns the "element type" of the given value/instruction \p V.
36/// For stores, returns the stored value type; for insertelement (when \p ReVec
37/// is off), the inserted operand type. For compares, the default is to return
38/// the result type (i1); when \p LookThroughCmp is true, returns the type of
39/// the compared operands instead, which is needed for vector width
40/// calculations (the width is determined by the operand type, not the i1
41/// result).
42Type *getValueType(Value *V, bool ReVec, bool LookThroughCmp = false);
43
44/// \returns the vector type of ScalarTy based on vectorization factor.
45Type *getWidenedType(Type *ScalarTy, unsigned VF);
46
47/// Returns the number of elements of the given type \p Ty, not less than \p Sz,
48/// which forms type, which splits by \p TTI into whole vector types during
49/// legalization.
50unsigned getFullVectorNumberOfElements(const TargetTransformInfo &TTI, Type *Ty,
51 unsigned Sz, bool ReVec);
52
53/// Returns the number of elements of the given type \p Ty, not greater than \p
54/// Sz, which forms type, which splits by \p TTI into whole vector types during
55/// legalization.
56unsigned getFloorFullVectorNumberOfElements(const TargetTransformInfo &TTI,
57 Type *Ty, unsigned Sz, bool ReVec);
58
59/// For a non-power-of-2 \p NumElts-wide integer div/rem \p Opcode, returns the
60/// padded full-register vector type if padding is structurally possible, or
61/// nullptr if the vector already fills a register or the opcode is not
62/// div/rem. Does not check profitability.
63FixedVectorType *getMaskedDivRemType(const TargetTransformInfo &TTI,
64 unsigned Opcode, Type *ScalarTy,
65 unsigned NumElts, bool ReVec);
66
67/// Returns true if widened type of \p Ty elements with size \p Sz represents
68/// full vector type, i.e. adding extra element results in extra parts upon type
69/// legalization.
70bool hasFullVectorsOrPowerOf2(const TargetTransformInfo &TTI, Type *Ty,
71 unsigned Sz, bool ReVec);
72
73} // namespace llvm::slpvectorizer
74
75#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)
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,...
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