LLVM 22.0.0git
VPlanUtils.cpp
Go to the documentation of this file.
1//===- VPlanUtils.cpp - VPlan-related utilities ---------------------------===//
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#include "VPlanUtils.h"
10#include "VPlanCFG.h"
11#include "VPlanDominatorTree.h"
12#include "VPlanPatternMatch.h"
13#include "llvm/ADT/TypeSwitch.h"
16
17using namespace llvm;
18using namespace llvm::VPlanPatternMatch;
19
21 return all_of(Def->users(),
22 [Def](const VPUser *U) { return U->usesFirstLaneOnly(Def); });
23}
24
26 return all_of(Def->users(),
27 [Def](const VPUser *U) { return U->usesFirstPartOnly(Def); });
28}
29
31 return all_of(Def->users(),
32 [Def](const VPUser *U) { return U->usesScalars(Def); });
33}
34
36 if (auto *E = dyn_cast<SCEVConstant>(Expr))
37 return Plan.getOrAddLiveIn(E->getValue());
38 // Skip SCEV expansion if Expr is a SCEVUnknown wrapping a non-instruction
39 // value. Otherwise the value may be defined in a loop and using it directly
40 // will break LCSSA form. The SCEV expansion takes care of preserving LCSSA
41 // form.
42 auto *U = dyn_cast<SCEVUnknown>(Expr);
43 if (U && !isa<Instruction>(U->getValue()))
44 return Plan.getOrAddLiveIn(U->getValue());
45 auto *Expanded = new VPExpandSCEVRecipe(Expr);
46 Plan.getEntry()->appendRecipe(Expanded);
47 return Expanded;
48}
49
50bool vputils::isHeaderMask(const VPValue *V, const VPlan &Plan) {
52 return true;
53
54 auto IsWideCanonicalIV = [](VPValue *A) {
58 };
59
60 VPValue *A, *B;
61
62 auto m_CanonicalScalarIVSteps =
64 m_One(), m_Specific(&Plan.getVF()));
65
67 return B == Plan.getTripCount() &&
68 (match(A, m_CanonicalScalarIVSteps) || IsWideCanonicalIV(A));
69
70 // For scalar plans, the header mask uses the scalar steps.
71 if (match(V, m_ICmp(m_CanonicalScalarIVSteps,
73 assert(Plan.hasScalarVFOnly() &&
74 "Non-scalar VF using scalar IV steps for header mask?");
75 return true;
76 }
77
78 return match(V, m_ICmp(m_VPValue(A), m_VPValue(B))) && IsWideCanonicalIV(A) &&
79 B == Plan.getBackedgeTakenCount();
80}
81
83 ScalarEvolution &SE, const Loop *L) {
84 if (V->isLiveIn()) {
85 Value *LiveIn = V->getLiveInIRValue();
86 if (LiveIn && SE.isSCEVable(LiveIn->getType()))
87 return SE.getSCEV(LiveIn);
88 return SE.getCouldNotCompute();
89 }
90
91 // TODO: Support constructing SCEVs for more recipes as needed.
92 return TypeSwitch<const VPRecipeBase *, const SCEV *>(V->getDefiningRecipe())
94 [](const VPExpandSCEVRecipe *R) { return R->getSCEV(); })
95 .Case<VPCanonicalIVPHIRecipe>([&SE, L](const VPCanonicalIVPHIRecipe *R) {
96 if (!L)
97 return SE.getCouldNotCompute();
98 const SCEV *Start = getSCEVExprForVPValue(R->getOperand(0), SE, L);
99 return SE.getAddRecExpr(Start, SE.getOne(Start->getType()), L,
101 })
102 .Case<VPWidenIntOrFpInductionRecipe>(
103 [&SE, L](const VPWidenIntOrFpInductionRecipe *R) {
104 const SCEV *Step = getSCEVExprForVPValue(R->getStepValue(), SE, L);
105 if (!L || isa<SCEVCouldNotCompute>(Step))
106 return SE.getCouldNotCompute();
107 const SCEV *Start =
108 getSCEVExprForVPValue(R->getStartValue(), SE, L);
109 return SE.getAddRecExpr(Start, Step, L, SCEV::FlagAnyWrap);
110 })
111 .Case<VPDerivedIVRecipe>([&SE, L](const VPDerivedIVRecipe *R) {
112 const SCEV *Start = getSCEVExprForVPValue(R->getOperand(0), SE, L);
113 const SCEV *IV = getSCEVExprForVPValue(R->getOperand(1), SE, L);
114 const SCEV *Scale = getSCEVExprForVPValue(R->getOperand(2), SE, L);
115 if (any_of(ArrayRef({Start, IV, Scale}), IsaPred<SCEVCouldNotCompute>))
116 return SE.getCouldNotCompute();
117
118 return SE.getAddExpr(SE.getTruncateOrSignExtend(Start, IV->getType()),
120 Scale, IV->getType())));
121 })
122 .Case<VPScalarIVStepsRecipe>([&SE, L](const VPScalarIVStepsRecipe *R) {
123 const SCEV *IV = getSCEVExprForVPValue(R->getOperand(0), SE, L);
124 const SCEV *Step = getSCEVExprForVPValue(R->getOperand(1), SE, L);
126 !Step->isOne())
127 return SE.getCouldNotCompute();
128 return SE.getMulExpr(SE.getTruncateOrSignExtend(IV, Step->getType()),
129 Step);
130 })
131 .Case<VPReplicateRecipe>([&SE, L](const VPReplicateRecipe *R) {
132 if (R->getOpcode() != Instruction::GetElementPtr)
133 return SE.getCouldNotCompute();
134
135 const SCEV *Base = getSCEVExprForVPValue(R->getOperand(0), SE, L);
137 return SE.getCouldNotCompute();
138
139 SmallVector<const SCEV *> IndexExprs;
140 for (VPValue *Index : drop_begin(R->operands())) {
141 const SCEV *IndexExpr = getSCEVExprForVPValue(Index, SE, L);
142 if (isa<SCEVCouldNotCompute>(IndexExpr))
143 return SE.getCouldNotCompute();
144 IndexExprs.push_back(IndexExpr);
145 }
146
147 Type *SrcElementTy = cast<GetElementPtrInst>(R->getUnderlyingInstr())
148 ->getSourceElementType();
149 return SE.getGEPExpr(Base, IndexExprs, SrcElementTy);
150 })
151 .Default([&SE](const VPRecipeBase *) { return SE.getCouldNotCompute(); });
152}
153
154/// Returns true if \p Opcode preserves uniformity, i.e., if all operands are
155/// uniform, the result will also be uniform.
156static bool preservesUniformity(unsigned Opcode) {
157 if (Instruction::isBinaryOp(Opcode) || Instruction::isCast(Opcode))
158 return true;
159 switch (Opcode) {
160 case Instruction::GetElementPtr:
161 case Instruction::ICmp:
162 case Instruction::FCmp:
163 case Instruction::Select:
167 return true;
168 default:
169 return false;
170 }
171}
172
174 // A live-in must be uniform across the scope of VPlan.
175 if (VPV->isLiveIn())
176 return true;
177
178 if (auto *Rep = dyn_cast<VPReplicateRecipe>(VPV)) {
179 const VPRegionBlock *RegionOfR = Rep->getRegion();
180 // Don't consider recipes in replicate regions as uniform yet; their first
181 // lane cannot be accessed when executing the replicate region for other
182 // lanes.
183 if (RegionOfR && RegionOfR->isReplicator())
184 return false;
185 return Rep->isSingleScalar() || (preservesUniformity(Rep->getOpcode()) &&
186 all_of(Rep->operands(), isSingleScalar));
187 }
191 if (auto *WidenR = dyn_cast<VPWidenRecipe>(VPV)) {
192 return preservesUniformity(WidenR->getOpcode()) &&
193 all_of(WidenR->operands(), isSingleScalar);
194 }
195 if (auto *VPI = dyn_cast<VPInstruction>(VPV))
196 return VPI->isSingleScalar() || VPI->isVectorToScalar() ||
197 (preservesUniformity(VPI->getOpcode()) &&
198 all_of(VPI->operands(), isSingleScalar));
199 if (auto *RR = dyn_cast<VPReductionRecipe>(VPV))
200 return !RR->isPartialReduction();
203 return true;
204 if (auto *Expr = dyn_cast<VPExpressionRecipe>(VPV))
205 return Expr->isSingleScalar();
206
207 // VPExpandSCEVRecipes must be placed in the entry and are always uniform.
208 return isa<VPExpandSCEVRecipe>(VPV);
209}
210
212 // Live-ins are uniform.
213 if (V->isLiveIn())
214 return true;
215
216 VPRecipeBase *R = V->getDefiningRecipe();
217 if (R && V->isDefinedOutsideLoopRegions()) {
218 if (match(V->getDefiningRecipe(),
220 return false;
221 return all_of(R->operands(), isUniformAcrossVFsAndUFs);
222 }
223
224 auto *CanonicalIV =
225 R->getParent()->getEnclosingLoopRegion()->getCanonicalIV();
226 // Canonical IV chain is uniform.
227 if (V == CanonicalIV || V == CanonicalIV->getBackedgeValue())
228 return true;
229
231 .Case<VPDerivedIVRecipe>([](const auto *R) { return true; })
232 .Case<VPReplicateRecipe>([](const auto *R) {
233 // Be conservative about side-effects, except for the
234 // known-side-effecting assumes and stores, which we know will be
235 // uniform.
236 return R->isSingleScalar() &&
237 (!R->mayHaveSideEffects() ||
238 isa<AssumeInst, StoreInst>(R->getUnderlyingInstr())) &&
239 all_of(R->operands(), isUniformAcrossVFsAndUFs);
240 })
241 .Case<VPWidenRecipe>([](const auto *R) {
242 return preservesUniformity(R->getOpcode()) &&
243 all_of(R->operands(), isUniformAcrossVFsAndUFs);
244 })
245 .Case<VPInstruction>([](const auto *VPI) {
246 return (VPI->isScalarCast() &&
247 isUniformAcrossVFsAndUFs(VPI->getOperand(0))) ||
248 (preservesUniformity(VPI->getOpcode()) &&
249 all_of(VPI->operands(), isUniformAcrossVFsAndUFs));
250 })
251 .Case<VPWidenCastRecipe>([](const auto *R) {
252 // A cast is uniform according to its operand.
253 return isUniformAcrossVFsAndUFs(R->getOperand(0));
254 })
255 .Default([](const VPRecipeBase *) { // A value is considered non-uniform
256 // unless proven otherwise.
257 return false;
258 });
259}
260
262 auto DepthFirst = vp_depth_first_shallow(Plan.getEntry());
263 auto I = find_if(DepthFirst, [&VPDT](VPBlockBase *VPB) {
264 return VPBlockUtils::isHeader(VPB, VPDT);
265 });
266 return I == DepthFirst.end() ? nullptr : cast<VPBasicBlock>(*I);
267}
268
270 if (!R)
271 return 1;
272 if (auto *RR = dyn_cast<VPReductionPHIRecipe>(R))
273 return RR->getVFScaleFactor();
274 if (auto *RR = dyn_cast<VPReductionRecipe>(R))
275 return RR->getVFScaleFactor();
276 if (auto *ER = dyn_cast<VPExpressionRecipe>(R))
277 return ER->getVFScaleFactor();
278 assert(
281 "getting scaling factor of reduction-start-vector not implemented yet");
282 return 1;
283}
284
285std::optional<VPValue *>
289 // Given a VPlan like the following (just including the recipes contributing
290 // to loop control exiting here, not the actual work), we're looking to match
291 // the recipes contributing to the uncountable exit condition comparison
292 // (here, vp<%4>) back to either live-ins or the address nodes for the load
293 // used as part of the uncountable exit comparison so that we can copy them
294 // to a preheader and rotate the address in the loop to the next vector
295 // iteration.
296 //
297 // Currently, the address of the load is restricted to a GEP with 2 operands
298 // and a live-in base address. This constraint may be relaxed later.
299 //
300 // VPlan ' for UF>=1' {
301 // Live-in vp<%0> = VF
302 // Live-in ir<64> = original trip-count
303 //
304 // entry:
305 // Successor(s): preheader, vector.ph
306 //
307 // vector.ph:
308 // Successor(s): vector loop
309 //
310 // <x1> vector loop: {
311 // vector.body:
312 // EMIT vp<%2> = CANONICAL-INDUCTION ir<0>
313 // vp<%3> = SCALAR-STEPS vp<%2>, ir<1>, vp<%0>
314 // CLONE ir<%ee.addr> = getelementptr ir<0>, vp<%3>
315 // WIDEN ir<%ee.load> = load ir<%ee.addr>
316 // WIDEN vp<%4> = icmp eq ir<%ee.load>, ir<0>
317 // EMIT vp<%5> = any-of vp<%4>
318 // EMIT vp<%6> = add vp<%2>, vp<%0>
319 // EMIT vp<%7> = icmp eq vp<%6>, ir<64>
320 // EMIT vp<%8> = or vp<%5>, vp<%7>
321 // EMIT branch-on-cond vp<%8>
322 // No successors
323 // }
324 // Successor(s): middle.block
325 //
326 // middle.block:
327 // Successor(s): preheader
328 //
329 // preheader:
330 // No successors
331 // }
332
333 // Find the uncountable loop exit condition.
334 auto *Region = Plan.getVectorLoopRegion();
335 VPValue *UncountableCondition = nullptr;
336 if (!match(Region->getExitingBasicBlock()->getTerminator(),
338 m_AnyOf(m_VPValue(UncountableCondition)), m_VPValue())))))
339 return std::nullopt;
340
342 Worklist.push_back(UncountableCondition);
343 while (!Worklist.empty()) {
344 VPValue *V = Worklist.pop_back_val();
345
346 // Any value defined outside the loop does not need to be copied.
347 if (V->isDefinedOutsideLoopRegions())
348 continue;
349
350 // FIXME: Remove the single user restriction; it's here because we're
351 // starting with the simplest set of loops we can, and multiple
352 // users means needing to add PHI nodes in the transform.
353 if (V->getNumUsers() > 1)
354 return std::nullopt;
355
356 VPValue *Op1, *Op2;
357 // Walk back through recipes until we find at least one load from memory.
358 if (match(V, m_ICmp(m_VPValue(Op1), m_VPValue(Op2)))) {
359 Worklist.push_back(Op1);
360 Worklist.push_back(Op2);
361 Recipes.push_back(V->getDefiningRecipe());
362 } else if (auto *Load = dyn_cast<VPWidenLoadRecipe>(V)) {
363 // Reject masked loads for the time being; they make the exit condition
364 // more complex.
365 if (Load->isMasked())
366 return std::nullopt;
367
368 VPValue *GEP = Load->getAddr();
370 return std::nullopt;
371
372 Recipes.push_back(Load);
373 Recipes.push_back(GEP->getDefiningRecipe());
374 GEPs.push_back(GEP->getDefiningRecipe());
375 } else
376 return std::nullopt;
377 }
378
379 return UncountableCondition;
380}
381
383 const VPDominatorTree &VPDT) {
384 auto *VPBB = dyn_cast<VPBasicBlock>(VPB);
385 if (!VPBB)
386 return false;
387
388 // If VPBB is in a region R, VPBB is a loop header if R is a loop region with
389 // VPBB as its entry, i.e., free of predecessors.
390 if (auto *R = VPBB->getParent())
391 return !R->isReplicator() && !VPBB->hasPredecessors();
392
393 // A header dominates its second predecessor (the latch), with the other
394 // predecessor being the preheader
395 return VPB->getPredecessors().size() == 2 &&
396 VPDT.dominates(VPB, VPB->getPredecessors()[1]);
397}
398
400 const VPDominatorTree &VPDT) {
401 // A latch has a header as its second successor, with its other successor
402 // leaving the loop. A preheader OTOH has a header as its first (and only)
403 // successor.
404 return VPB->getNumSuccessors() == 2 &&
405 VPBlockUtils::isHeader(VPB->getSuccessors()[1], VPDT);
406}
407
408std::optional<MemoryLocation>
410 auto *M = dyn_cast<VPIRMetadata>(&R);
411 if (!M)
412 return std::nullopt;
414 // Populate noalias metadata from VPIRMetadata.
415 if (MDNode *NoAliasMD = M->getMetadata(LLVMContext::MD_noalias))
416 Loc.AATags.NoAlias = NoAliasMD;
417 if (MDNode *AliasScopeMD = M->getMetadata(LLVMContext::MD_alias_scope))
418 Loc.AATags.Scope = AliasScopeMD;
419 return Loc;
420}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Hexagon Common GEP
#define I(x, y, z)
Definition MD5.cpp:57
This file provides utility analysis objects describing memory locations.
This file implements the TypeSwitch template, which mimics a switch() statement whose cases are type ...
This file implements dominator tree analysis for a single level of a VPlan's H-CFG.
static std::optional< unsigned > getOpcode(ArrayRef< VPValue * > Values)
Returns the opcode of Values or ~0 if they do not all agree.
Definition VPlanSLP.cpp:247
static bool preservesUniformity(unsigned Opcode)
Returns true if Opcode preserves uniformity, i.e., if all operands are uniform, the result will also ...
static const uint32_t IV[8]
Definition blake3_impl.h:83
bool dominates(const DomTreeNodeBase< NodeT > *A, const DomTreeNodeBase< NodeT > *B) const
dominates - Returns true iff A dominates B.
bool isCast() const
bool isBinaryOp() const
Represents a single loop in the control flow graph.
Definition LoopInfo.h:40
Metadata node.
Definition Metadata.h:1078
Representation for a specific memory location.
This class represents an analyzed expression in the program.
LLVM_ABI bool isOne() const
Return true if the expression is a constant one.
LLVM_ABI Type * getType() const
Return the LLVM type of this SCEV expression.
The main scalar evolution driver.
LLVM_ABI const SCEV * getSCEV(Value *V)
Return a SCEV expression for the full generality of the specified expression.
const SCEV * getOne(Type *Ty)
Return a SCEV for the constant 1 of a specific type.
LLVM_ABI const SCEV * getAddRecExpr(const SCEV *Start, const SCEV *Step, const Loop *L, SCEV::NoWrapFlags Flags)
Get an add recurrence expression for the specified loop.
LLVM_ABI bool isSCEVable(Type *Ty) const
Test if values of the given type are analyzable within the SCEV framework.
LLVM_ABI const SCEV * getCouldNotCompute()
LLVM_ABI const SCEV * getGEPExpr(GEPOperator *GEP, ArrayRef< const SCEV * > IndexExprs)
Returns an expression for a GEP.
LLVM_ABI const SCEV * getMulExpr(SmallVectorImpl< const SCEV * > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
Get a canonical multiply expression, or something simpler if possible.
LLVM_ABI const SCEV * getAddExpr(SmallVectorImpl< const SCEV * > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
Get a canonical add expression, or something simpler if possible.
LLVM_ABI const SCEV * getTruncateOrSignExtend(const SCEV *V, Type *Ty, unsigned Depth=0)
Return a SCEV corresponding to a conversion of the input value to the specified type.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This class implements a switch-like dispatch statement for a value of 'T' using dyn_cast functionalit...
Definition TypeSwitch.h:88
TypeSwitch< T, ResultT > & Case(CallableT &&caseFn)
Add a case on the given type.
Definition TypeSwitch.h:97
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
VPBasicBlock serves as the leaf of the Hierarchical Control-Flow Graph.
Definition VPlan.h:3968
void appendRecipe(VPRecipeBase *Recipe)
Augment the existing recipes of a VPBasicBlock with an additional Recipe as the last recipe.
Definition VPlan.h:4043
A recipe for vectorizing a phi-node as a sequence of mask-based select instructions.
Definition VPlan.h:2516
VPBlockBase is the building block of the Hierarchical Control-Flow Graph.
Definition VPlan.h:81
size_t getNumSuccessors() const
Definition VPlan.h:219
const VPBlocksTy & getPredecessors() const
Definition VPlan.h:204
const VPBlocksTy & getSuccessors() const
Definition VPlan.h:198
static bool isLatch(const VPBlockBase *VPB, const VPDominatorTree &VPDT)
Returns true if VPB is a loop latch, using isHeader().
static bool isHeader(const VPBlockBase *VPB, const VPDominatorTree &VPDT)
Returns true if VPB is a loop header, based on regions or VPDT in their absence.
Canonical scalar induction phi of the vector loop.
Definition VPlan.h:3551
A recipe for converting the input value IV value to the corresponding value of an IV with different s...
Definition VPlan.h:3718
Template specialization of the standard LLVM dominator tree utility for VPBlockBases.
Recipe to expand a SCEV expression.
Definition VPlan.h:3513
@ ReductionStartVector
Start vector for reductions with 3 operands: the original start value, the identity value for the red...
Definition VPlan.h:1121
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
Definition VPlan.h:387
VPRegionBlock represents a collection of VPBasicBlocks and VPRegionBlocks which form a Single-Entry-S...
Definition VPlan.h:4156
bool isReplicator() const
An indicator whether this region is to generate multiple replicated instances of output IR correspond...
Definition VPlan.h:4224
VPCanonicalIVPHIRecipe * getCanonicalIV()
Returns the canonical induction recipe of the region.
Definition VPlan.h:4254
VPReplicateRecipe replicates a given instruction producing multiple scalar copies of the original sca...
Definition VPlan.h:2939
A recipe for handling phi nodes of integer and floating-point inductions, producing their scalar valu...
Definition VPlan.h:3788
This class augments VPValue with operands which provide the inverse def-use edges from VPValue's user...
Definition VPlanValue.h:202
operand_range operands()
Definition VPlanValue.h:270
This is the base class of the VPlan Def/Use graph, used for modeling the data flow into,...
Definition VPlanValue.h:46
VPRecipeBase * getDefiningRecipe()
Returns the recipe defining this VPValue or nullptr if it is not defined by a recipe,...
Definition VPlan.cpp:131
bool isLiveIn() const
Returns true if this VPValue is a live-in, i.e. defined outside the VPlan.
Definition VPlanValue.h:176
A recipe to compute a pointer to the last element of each part of a widened memory access for widened...
Definition VPlan.h:1911
A recipe to compute the pointers for widened memory accesses of IndexTy.
Definition VPlan.h:1971
A recipe for handling GEP instructions.
Definition VPlan.h:1848
A recipe for handling phi nodes of integer and floating-point inductions, producing their vector valu...
Definition VPlan.h:2192
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
Definition VPlan.h:4286
VPBasicBlock * getEntry()
Definition VPlan.h:4375
VPValue & getVF()
Returns the VF of the vector loop region.
Definition VPlan.h:4469
VPValue * getTripCount() const
The trip count of the original loop.
Definition VPlan.h:4437
VPValue * getBackedgeTakenCount() const
Definition VPlan.h:4463
LLVM_ABI_FOR_TEST VPRegionBlock * getVectorLoopRegion()
Returns the VPRegionBlock of the vector loop.
Definition VPlan.cpp:1011
VPValue * getOrAddLiveIn(Value *V)
Gets the live-in VPValue for V or adds a new live-in (if none exists yet) for V.
Definition VPlan.h:4529
bool hasScalarVFOnly() const
Definition VPlan.h:4498
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:256
OneUse_match< SubPat > m_OneUse(const SubPat &SP)
bool match(Val *V, const Pattern &P)
specificval_ty m_Specific(const Value *V)
Match if we have a specific specified value.
cst_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
CmpClass_match< LHS, RHS, ICmpInst > m_ICmp(CmpPredicate &Pred, const LHS &L, const RHS &R)
VPInstruction_match< VPInstruction::AnyOf > m_AnyOf()
AllRecipe_commutative_match< Instruction::Or, Op0_t, Op1_t > m_c_BinaryOr(const Op0_t &Op0, const Op1_t &Op1)
VPScalarIVSteps_match< Op0_t, Op1_t, Op2_t > m_ScalarIVSteps(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
GEPLikeRecipe_match< Op0_t, Op1_t > m_GetElementPtr(const Op0_t &Op0, const Op1_t &Op1)
VPInstruction_match< VPInstruction::ActiveLaneMask, Op0_t, Op1_t, Op2_t > m_ActiveLaneMask(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2)
class_match< VPValue > m_VPValue()
Match an arbitrary VPValue and ignore it.
bind_ty< VPInstruction > m_VPInstruction(VPInstruction *&V)
Match a VPInstruction, capturing if we match.
VPInstruction_match< VPInstruction::BranchOnCond > m_BranchOnCond()
bool isSingleScalar(const VPValue *VPV)
Returns true if VPV is a single scalar, either because it produces the same value for all lanes or on...
bool isUniformAcrossVFsAndUFs(VPValue *V)
Checks if V is uniform across all VF lanes and UF parts.
VPValue * getOrCreateVPValueForSCEVExpr(VPlan &Plan, const SCEV *Expr)
Get or create a VPValue that corresponds to the expansion of Expr.
VPBasicBlock * getFirstLoopHeader(VPlan &Plan, VPDominatorTree &VPDT)
Returns the header block of the first, top-level loop, or null if none exist.
bool onlyFirstPartUsed(const VPValue *Def)
Returns true if only the first part of Def is used.
std::optional< MemoryLocation > getMemoryLocation(const VPRecipeBase &R)
Return a MemoryLocation for R with noalias metadata populated from R, if the recipe is supported and ...
bool onlyFirstLaneUsed(const VPValue *Def)
Returns true if only the first lane of Def is used.
bool onlyScalarValuesUsed(const VPValue *Def)
Returns true if only scalar values of Def are used by all users.
unsigned getVFScaleFactor(VPRecipeBase *R)
Get the VF scaling factor applied to the recipe's output, if the recipe has one.
bool isHeaderMask(const VPValue *V, const VPlan &Plan)
Return true if V is a header mask in Plan.
LLVM_ABI_FOR_TEST std::optional< VPValue * > getRecipesForUncountableExit(VPlan &Plan, SmallVectorImpl< VPRecipeBase * > &Recipes, SmallVectorImpl< VPRecipeBase * > &GEPs)
Returns the VPValue representing the uncountable exit comparison used by AnyOf if the recipes it depe...
const SCEV * getSCEVExprForVPValue(const VPValue *V, ScalarEvolution &SE, const Loop *L=nullptr)
Return the SCEV expression for V.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
Definition STLExtras.h:316
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:1737
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
iterator_range< df_iterator< VPBlockShallowTraversalWrapper< VPBlockBase * > > > vp_depth_first_shallow(VPBlockBase *G)
Returns an iterator range to traverse the graph starting at G in depth-first order.
Definition VPlanCFG.h:216
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1744
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1770
@ Default
The result values are uniform if and only if all operands are uniform.
Definition Uniformity.h:20
constexpr detail::IsaCheckPredicate< Types... > IsaPred
Function object wrapper for the llvm::isa type check.
Definition Casting.h:866
A recipe for widening select instructions.
Definition VPlan.h:1801