LLVM 22.0.0git
VPlanAnalysis.h
Go to the documentation of this file.
1//===- VPlanAnalysis.h - Various Analyses working on VPlan ------*- 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#ifndef LLVM_TRANSFORMS_VECTORIZE_VPLANANALYSIS_H
10#define LLVM_TRANSFORMS_VECTORIZE_VPLANANALYSIS_H
11
12#include "llvm/ADT/DenseMap.h"
13#include "llvm/ADT/DenseSet.h"
14#include "llvm/ADT/MapVector.h"
15#include "llvm/IR/Type.h"
16
17namespace llvm {
18
19class LLVMContext;
20class VPValue;
21class VPBlendRecipe;
22class VPInstruction;
23class VPWidenRecipe;
24class VPWidenCallRecipe;
25class VPWidenIntOrFpInductionRecipe;
26class VPWidenMemoryRecipe;
27struct VPWidenSelectRecipe;
28class VPReplicateRecipe;
29class VPRecipeBase;
30class VPlan;
31class Value;
32class TargetTransformInfo;
33class Type;
34
35/// An analysis for type-inference for VPValues.
36/// It infers the scalar type for a given VPValue by bottom-up traversing
37/// through defining recipes until root nodes with known types are reached (e.g.
38/// live-ins or load recipes). The types are then propagated top down through
39/// operations.
40/// Note that the analysis caches the inferred types. A new analysis object must
41/// be constructed once a VPlan has been modified in a way that invalidates any
42/// of the previously inferred types.
45 /// Type of the canonical induction variable. Used for all VPValues without
46 /// any underlying IR value (like the vector trip count or the backedge-taken
47 /// count).
48 Type *CanonicalIVTy;
49 LLVMContext &Ctx;
50
51 Type *inferScalarTypeForRecipe(const VPBlendRecipe *R);
52 Type *inferScalarTypeForRecipe(const VPInstruction *R);
53 Type *inferScalarTypeForRecipe(const VPWidenCallRecipe *R);
54 Type *inferScalarTypeForRecipe(const VPWidenRecipe *R);
55 Type *inferScalarTypeForRecipe(const VPWidenIntOrFpInductionRecipe *R);
56 Type *inferScalarTypeForRecipe(const VPWidenMemoryRecipe *R);
57 Type *inferScalarTypeForRecipe(const VPWidenSelectRecipe *R);
58 Type *inferScalarTypeForRecipe(const VPReplicateRecipe *R);
59
60public:
61 VPTypeAnalysis(const VPlan &Plan);
62
63 /// Infer the type of \p V. Returns the scalar type of \p V.
64 Type *inferScalarType(const VPValue *V);
65
66 /// Return the LLVMContext used by the analysis.
67 LLVMContext &getContext() { return Ctx; }
68};
69
70// Collect a VPlan's ephemeral recipes (those used only by an assume).
71void collectEphemeralRecipesForVPlan(VPlan &Plan,
72 DenseSet<VPRecipeBase *> &EphRecipes);
73
74/// A struct that represents some properties of the register usage
75/// of a loop.
77 /// Holds the number of loop invariant values that are used in the loop.
78 /// The key is ClassID of target-provided register class.
80 /// Holds the maximum number of concurrent live intervals in the loop.
81 /// The key is ClassID of target-provided register class.
83
84 /// Check if any of the tracked live intervals exceeds the number of
85 /// available registers for the target. If non-zero, OverrideMaxNumRegs
86 /// is used in place of the target's number of registers.
88 unsigned OverrideMaxNumRegs = 0) const;
89};
90
91/// Estimate the register usage for \p Plan and vectorization factors in \p VFs
92/// by calculating the highest number of values that are live at a single
93/// location as a rough estimate. Returns the register usage for each VF in \p
94/// VFs.
97 const SmallPtrSetImpl<const Value *> &ValuesToIgnore);
98
99} // end namespace llvm
100
101#endif // LLVM_TRANSFORMS_VECTORIZE_VPLANANALYSIS_H
RelocType Type
Definition: COFFYAML.cpp:410
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
This file implements a map that provides insertion order iteration.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:380
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
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:45
A recipe for vectorizing a phi-node as a sequence of mask-based select instructions.
Definition: VPlan.h:2374
This is a concrete Recipe that models a single VPlan-level instruction.
Definition: VPlan.h:967
VPReplicateRecipe replicates a given instruction producing multiple scalar copies of the original sca...
Definition: VPlan.h:2731
An analysis for type-inference for VPValues.
Definition: VPlanAnalysis.h:43
LLVMContext & getContext()
Return the LLVMContext used by the analysis.
Definition: VPlanAnalysis.h:67
Type * inferScalarType(const VPValue *V)
Infer the type of V. Returns the scalar type of V.
A recipe for widening Call instructions using library calls.
Definition: VPlan.h:1613
A recipe for handling phi nodes of integer and floating-point inductions, producing their vector valu...
Definition: VPlan.h:2088
A common base class for widening memory operations.
Definition: VPlan.h:3008
VPWidenRecipe is a recipe for producing a widened instruction using the opcode and operands of the re...
Definition: VPlan.h:1424
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
Definition: VPlan.h:3930
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
SmallVector< VPRegisterUsage, 8 > calculateRegisterUsageForPlan(VPlan &Plan, ArrayRef< ElementCount > VFs, const TargetTransformInfo &TTI, const SmallPtrSetImpl< const Value * > &ValuesToIgnore)
Estimate the register usage for Plan and vectorization factors in VFs by calculating the highest numb...
void collectEphemeralRecipesForVPlan(VPlan &Plan, DenseSet< VPRecipeBase * > &EphRecipes)
A MapVector that performs no allocations if smaller than a certain size.
Definition: MapVector.h:249
A struct that represents some properties of the register usage of a loop.
Definition: VPlanAnalysis.h:76
SmallMapVector< unsigned, unsigned, 4 > MaxLocalUsers
Holds the maximum number of concurrent live intervals in the loop.
Definition: VPlanAnalysis.h:82
bool exceedsMaxNumRegs(const TargetTransformInfo &TTI, unsigned OverrideMaxNumRegs=0) const
Check if any of the tracked live intervals exceeds the number of available registers for the target.
SmallMapVector< unsigned, unsigned, 4 > LoopInvariantRegs
Holds the number of loop invariant values that are used in the loop.
Definition: VPlanAnalysis.h:79
A recipe for widening select instructions.
Definition: VPlan.h:1707