LLVM 20.0.0git
VPlanUtils.h
Go to the documentation of this file.
1//===- VPlanUtils.h - VPlan-related utilities -------------------*- 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_VPLANUTILS_H
10#define LLVM_TRANSFORMS_VECTORIZE_VPLANUTILS_H
11
12#include "VPlan.h"
13
14namespace llvm {
15class ScalarEvolution;
16class SCEV;
17} // namespace llvm
18
19namespace llvm::vputils {
20/// Returns true if only the first lane of \p Def is used.
21bool onlyFirstLaneUsed(const VPValue *Def);
22
23/// Returns true if only the first part of \p Def is used.
24bool onlyFirstPartUsed(const VPValue *Def);
25
26/// Get or create a VPValue that corresponds to the expansion of \p Expr. If \p
27/// Expr is a SCEVConstant or SCEVUnknown, return a VPValue wrapping the live-in
28/// value. Otherwise return a VPExpandSCEVRecipe to expand \p Expr. If \p Plan's
29/// pre-header already contains a recipe expanding \p Expr, return it. If not,
30/// create a new one.
32 ScalarEvolution &SE);
33
34/// Return the SCEV expression for \p V. Returns SCEVCouldNotCompute if no
35/// SCEV expression could be constructed.
37
38/// Returns true if \p VPV is uniform after vectorization.
39inline bool isUniformAfterVectorization(const VPValue *VPV) {
40 // A value defined outside the vector region must be uniform after
41 // vectorization inside a vector region.
43 return true;
44 const VPRecipeBase *Def = VPV->getDefiningRecipe();
45 assert(Def && "Must have definition for value defined inside vector region");
46 if (auto *Rep = dyn_cast<VPReplicateRecipe>(Def))
47 return Rep->isUniform();
48 if (auto *GEP = dyn_cast<VPWidenGEPRecipe>(Def))
49 return all_of(GEP->operands(), isUniformAfterVectorization);
50 if (auto *VPI = dyn_cast<VPInstruction>(Def))
51 return VPI->isSingleScalar() || VPI->isVectorToScalar();
52 return false;
53}
54
55/// Return true if \p V is a header mask in \p Plan.
56bool isHeaderMask(const VPValue *V, VPlan &Plan);
57
58/// Checks if \p V is uniform across all VF lanes and UF parts. It is considered
59/// as such if it is either loop invariant (defined outside the vector region)
60/// or its operand is known to be uniform across all VFs and UFs (e.g.
61/// VPDerivedIV or VPCanonicalIVPHI).
63
64} // end namespace llvm::vputils
65
66#endif
Hexagon Common GEP
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains the declarations of the Vectorization Plan base classes:
This class represents an analyzed expression in the program.
The main scalar evolution driver.
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
Definition: VPlan.h:720
bool isDefinedOutsideLoopRegions() const
Returns true if the VPValue is defined outside any loop region.
Definition: VPlan.cpp:1417
VPRecipeBase * getDefiningRecipe()
Returns the recipe defining this VPValue or nullptr if it is not defined by a recipe,...
Definition: VPlan.cpp:123
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
Definition: VPlan.h:3761
bool isUniformAfterVectorization(const VPValue *VPV)
Returns true if VPV is uniform after vectorization.
Definition: VPlanUtils.h:39
VPValue * getOrCreateVPValueForSCEVExpr(VPlan &Plan, const SCEV *Expr, ScalarEvolution &SE)
Get or create a VPValue that corresponds to the expansion of Expr.
Definition: VPlanUtils.cpp:26
bool isUniformAcrossVFsAndUFs(VPValue *V)
Checks if V is uniform across all VF lanes and UF parts.
Definition: VPlanUtils.cpp:76
bool onlyFirstPartUsed(const VPValue *Def)
Returns true if only the first part of Def is used.
Definition: VPlanUtils.cpp:21
const SCEV * getSCEVExprForVPValue(VPValue *V, ScalarEvolution &SE)
Return the SCEV expression for V.
Definition: VPlanUtils.cpp:65
bool onlyFirstLaneUsed(const VPValue *Def)
Returns true if only the first lane of Def is used.
Definition: VPlanUtils.cpp:16
bool isHeaderMask(const VPValue *V, VPlan &Plan)
Return true if V is a header mask in Plan.
Definition: VPlanUtils.cpp:43
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1739