LLVM 24.0.0git
LoopVectorizationPlanner.cpp
Go to the documentation of this file.
1//===- LoopVectorizationPlanner.cpp - VF selection and planning -----------===//
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/// \file
10/// This file implements VFSelectionContext methods for loop vectorization
11/// VF selection, independent of cost-modeling decisions.
12///
13//===----------------------------------------------------------------------===//
14
16#include "VPlanUtils.h"
22#include "llvm/Support/Debug.h"
26
27using namespace llvm;
28using namespace LoopVectorizationUtils;
29
30#define DEBUG_TYPE "loop-vectorize"
31
33
35 "vectorizer-maximize-bandwidth", cl::init(false), cl::Hidden,
36 cl::desc("Maximize bandwidth when selecting vectorization factor which "
37 "will be determined by the smallest type in loop."));
38
40 "vectorizer-maximize-bandwidth-for-vector-calls", cl::init(true),
42 cl::desc("Try wider VFs if they enable the use of vector variants"));
43
45 "vectorizer-consider-reg-pressure", cl::init(false), cl::Hidden,
46 cl::desc("Discard VFs if their register pressure is too high."));
47
49 "force-target-supports-scalable-vectors", cl::init(false), cl::Hidden,
51 "Pretend that scalable vectors are supported, even if the target does "
52 "not support them. This flag should only be used for testing."));
53
55 "prefer-inloop-reductions", cl::init(false), cl::Hidden,
56 cl::desc("Prefer in-loop vector reductions, "
57 "overriding the targets preference."));
58
59/// Note: This currently only applies to `llvm.masked.load` and
60/// `llvm.masked.store`. TODO: Extend this to cover other operations as needed.
62 "force-target-supports-masked-memory-ops", cl::init(false), cl::Hidden,
63 cl::desc("Assume the target supports masked memory operations (used for "
64 "testing)."));
65
67 "force-target-supports-gather-scatter-ops", cl::init(false), cl::Hidden,
68 cl::desc("Assume the target supports gather/scatter operations (used for "
69 "testing)."));
70
72 "scalable-epilogue-vf-cost-scale-factor", cl::init(2.0), cl::Hidden,
73 cl::desc("Scale the cost of scalable epilogue VFs by this factor."));
74
75/// Write a \p DebugMsg about vectorization to the debug output stream. If \p I
76/// is passed, the message relates to that particular instruction.
77#ifndef NDEBUG
78static void debugVectorizationMessage(const StringRef Prefix,
79 const StringRef DebugMsg,
80 Instruction *I) {
81 dbgs() << "LV: " << Prefix << DebugMsg;
82 if (I != nullptr)
83 dbgs() << " " << *I;
84 else
85 dbgs() << '.';
86 dbgs() << '\n';
87}
88#endif
89
90/// Create an analysis remark that explains why vectorization failed
91/// \p RemarkName is the identifier for the remark. If \p I is passed it is an
92/// instruction that prevents vectorization. Otherwise \p TheLoop is used for
93/// the location of the remark. If \p DL is passed, use it as debug location for
94/// the remark. \return the remark object that can be streamed to.
96 const Loop *TheLoop,
98 DebugLoc DL = {}) {
99 BasicBlock *CodeRegion = I ? I->getParent() : TheLoop->getHeader();
100 // If debug location is attached to the instruction, use it. Otherwise if DL
101 // was not provided, use the loop's.
102 if (I && I->getDebugLoc())
103 DL = I->getDebugLoc();
104 else if (!DL)
105 DL = TheLoop->getStartLoc();
106
107 return OptimizationRemarkAnalysis(DEBUG_TYPE, RemarkName, DL, CodeRegion);
108}
109
111 const StringRef DebugMsg, const StringRef OREMsg, const StringRef ORETag,
112 OptimizationRemarkEmitter *ORE, const Loop *TheLoop, Instruction *I) {
113 LLVM_DEBUG(debugVectorizationMessage("Not vectorizing: ", DebugMsg, I));
114 ORE->emit(createLVAnalysis(ORETag, TheLoop, I)
115 << "loop not vectorized: " << OREMsg);
116}
117
119 const StringRef Msg, const StringRef ORETag, OptimizationRemarkEmitter *ORE,
120 const Loop *TheLoop, Instruction *I, DebugLoc DL) {
122 ORE->emit(createLVAnalysis(ORETag, TheLoop, I, DL) << Msg);
123}
124
126 Loop *TheLoop,
127 ElementCount VFWidth,
128 unsigned IC) {
130 "Vectorizing: ", TheLoop->isInnermost() ? "innermost loop" : "outer loop",
131 nullptr));
132 StringRef LoopType = TheLoop->isInnermost() ? "" : "outer ";
133 ORE->emit([&]() {
134 return OptimizationRemark(DEBUG_TYPE, "Vectorized", TheLoop->getStartLoc(),
135 TheLoop->getHeader())
136 << "vectorized " << LoopType << "loop (vectorization width: "
137 << ore::NV("VectorizationFactor", VFWidth)
138 << ", interleaved count: " << ore::NV("InterleaveCount", IC) << ")";
139 });
140}
141
143 Align Alignment,
144 unsigned AddressSpace) const {
146 (IsLoad ? TTI.isLegalMaskedLoad(ScalarTy, Alignment, AddressSpace)
147 : TTI.isLegalMaskedStore(ScalarTy, Alignment, AddressSpace));
148}
149
151 ElementCount VF) const {
152 bool LI = isa<LoadInst>(V);
153 bool SI = isa<StoreInst>(V);
154 if (!LI && !SI)
155 return false;
156 auto *Ty = getLoadStoreType(V);
158 if (VF.isVector())
159 Ty = VectorType::get(Ty, VF);
161 (LI && TTI.isLegalMaskedGather(Ty, Align)) ||
162 (SI && TTI.isLegalMaskedScatter(Ty, Align));
163}
164
166 return TTI.supportsScalableVectors() || ForceTargetSupportsScalableVectors ||
168}
169
170bool VFSelectionContext::useMaxBandwidth(bool IsScalable) const {
174 return MaximizeBandwidth || (MaximizeBandwidth.getNumOccurrences() == 0 &&
175 (TTI.shouldMaximizeVectorBandwidth(RegKind) ||
177 Legal->hasVectorCallVariants())));
178}
179
181 if (ConsiderRegPressure.getNumOccurrences())
182 return ConsiderRegPressure;
183
184 // TODO: We should eventually consider register pressure for all targets. The
185 // TTI hook is temporary whilst target-specific issues are being fixed.
186 if (TTI.shouldConsiderVectorizationRegPressure())
187 return true;
188
189 if (!useMaxBandwidth(VF.isScalable()))
190 return false;
191 // Only calculate register pressure for VFs enabled by MaxBandwidth.
193 VF, VF.isScalable() ? MaxPermissibleVFWithoutMaxBW.ScalableVF
194 : MaxPermissibleVFWithoutMaxBW.FixedVF);
195}
196
197ElementCount VFSelectionContext::clampVFByMaxTripCount(
198 ElementCount VF, unsigned MaxTripCount, unsigned UserIC,
199 bool FoldTailByMasking, bool RequiresScalarEpilogue) const {
200 unsigned EstimatedVF = VF.getKnownMinValue();
201 if (VF.isScalable() && F.hasFnAttribute(Attribute::VScaleRange)) {
202 auto Attr = F.getFnAttribute(Attribute::VScaleRange);
203 auto Min = Attr.getVScaleRangeMin();
204 EstimatedVF *= Min;
205 }
206
207 // When a scalar epilogue is required, at least one iteration of the scalar
208 // loop has to execute. Adjust MaxTripCount accordingly to avoid picking a
209 // max VF that results in a dead vector loop.
210 if (MaxTripCount > 0 && RequiresScalarEpilogue)
211 MaxTripCount -= 1;
212
213 // When the user specifies an interleave count, we need to ensure that
214 // VF * UserIC <= MaxTripCount to avoid a dead vector loop.
215 unsigned IC = UserIC > 0 ? UserIC : 1;
216 unsigned EstimatedVFTimesIC = EstimatedVF * IC;
217
218 if (MaxTripCount && MaxTripCount <= EstimatedVFTimesIC &&
219 (!FoldTailByMasking || isPowerOf2_32(MaxTripCount))) {
220 // If upper bound loop trip count (TC) is known at compile time there is no
221 // point in choosing VF greater than TC / IC (as done in the loop below).
222 // Select maximum power of two which doesn't exceed TC / IC. If VF is
223 // scalable, we only fall back on a fixed VF when the TC is less than or
224 // equal to the known number of lanes.
225 auto ClampedUpperTripCount = llvm::bit_floor(MaxTripCount / IC);
226 if (ClampedUpperTripCount == 0)
227 ClampedUpperTripCount = 1;
228 LLVM_DEBUG(dbgs() << "LV: Clamping the MaxVF to maximum power of two not "
229 "exceeding the constant trip count"
230 << (UserIC > 0 ? " divided by UserIC" : "") << ": "
231 << ClampedUpperTripCount << "\n");
232 return ElementCount::get(ClampedUpperTripCount,
233 FoldTailByMasking ? VF.isScalable() : false);
234 }
235 return VF;
236}
237
238ElementCount VFSelectionContext::getMaximizedVFForTarget(
239 unsigned MaxTripCount, unsigned SmallestType, unsigned WidestType,
240 ElementCount MaxSafeVF, unsigned UserIC, bool FoldTailByMasking,
241 bool RequiresScalarEpilogue) {
242 bool ComputeScalableMaxVF = MaxSafeVF.isScalable();
243 const TypeSize WidestRegister = TTI.getRegisterBitWidth(
244 ComputeScalableMaxVF ? TargetTransformInfo::RGK_ScalableVector
246
247 // Convenience function to return the minimum of two ElementCounts.
248 auto MinVF = [](const ElementCount &LHS, const ElementCount &RHS) {
249 assert((LHS.isScalable() == RHS.isScalable()) &&
250 "Scalable flags must match");
252 };
253
254 // Ensure MaxVF is a power of 2; the dependence distance bound may not be.
255 // Note that both WidestRegister and WidestType may not be a powers of 2.
256 auto MaxVectorElementCount = ElementCount::get(
257 llvm::bit_floor(WidestRegister.getKnownMinValue() / WidestType),
258 ComputeScalableMaxVF);
259 MaxVectorElementCount = MinVF(MaxVectorElementCount, MaxSafeVF);
260 LLVM_DEBUG(dbgs() << "LV: The Widest register safe to use is: "
261 << (MaxVectorElementCount * WidestType) << " bits.\n");
262
263 if (!MaxVectorElementCount) {
264 LLVM_DEBUG(dbgs() << "LV: The target has no "
265 << (ComputeScalableMaxVF ? "scalable" : "fixed")
266 << " vector registers.\n");
267 return ElementCount::getFixed(1);
268 }
269
270 ElementCount MaxVF =
271 clampVFByMaxTripCount(MaxVectorElementCount, MaxTripCount, UserIC,
272 FoldTailByMasking, RequiresScalarEpilogue);
273 // If the MaxVF was already clamped, there's no point in trying to pick a
274 // larger one.
275 if (MaxVF != MaxVectorElementCount)
276 return MaxVF;
277
278 if (MaxVF.isScalable())
279 MaxPermissibleVFWithoutMaxBW.ScalableVF = MaxVF;
280 else
281 MaxPermissibleVFWithoutMaxBW.FixedVF = MaxVF;
282
283 if (useMaxBandwidth(ComputeScalableMaxVF)) {
284 auto MaxVectorElementCountMaxBW = ElementCount::get(
285 llvm::bit_floor(WidestRegister.getKnownMinValue() / SmallestType),
286 ComputeScalableMaxVF);
287 MaxVF = MinVF(MaxVectorElementCountMaxBW, MaxSafeVF);
288
289 if (ElementCount MinVF =
290 TTI.getMinimumVF(SmallestType, ComputeScalableMaxVF)) {
291 if (ElementCount::isKnownLT(MaxVF, MinVF)) {
292 LLVM_DEBUG(dbgs() << "LV: Overriding calculated MaxVF(" << MaxVF
293 << ") with target's minimum: " << MinVF << '\n');
294 MaxVF = MinVF;
295 }
296 }
297
298 MaxVF = clampVFByMaxTripCount(MaxVF, MaxTripCount, UserIC,
299 FoldTailByMasking, RequiresScalarEpilogue);
300 }
301 return MaxVF;
302}
303
304std::optional<unsigned> llvm::getMaxVScale(const Function &F,
305 const TargetTransformInfo &TTI) {
306 if (std::optional<unsigned> MaxVScale = TTI.getMaxVScale())
307 return MaxVScale;
308
309 if (F.hasFnAttribute(Attribute::VScaleRange))
310 return F.getFnAttribute(Attribute::VScaleRange).getVScaleRangeMax();
311
312 return std::nullopt;
313}
314
315bool VFSelectionContext::isScalableVectorizationAllowed() {
316 if (IsScalableVectorizationAllowed)
317 return *IsScalableVectorizationAllowed;
318
319 IsScalableVectorizationAllowed = false;
321 return false;
322
323 if (Hints->isScalableVectorizationDisabled()) {
324 reportVectorizationInfo("Scalable vectorization is explicitly disabled",
325 "ScalableVectorizationDisabled", ORE, TheLoop);
326 return false;
327 }
328
329 LLVM_DEBUG(dbgs() << "LV: Scalable vectorization is available\n");
330
331 auto MaxScalableVF = ElementCount::getScalable(
332 std::numeric_limits<ElementCount::ScalarTy>::max());
333
334 // Test that the loop-vectorizer can legalize all operations for this MaxVF.
335 // FIXME: While for scalable vectors this is currently sufficient, this should
336 // be replaced by a more detailed mechanism that filters out specific VFs,
337 // instead of invalidating vectorization for a whole set of VFs based on the
338 // MaxVF.
339
340 // Disable scalable vectorization if the loop contains unsupported reductions.
341 if (!all_of(Legal->getReductionVars(), [&](const auto &Reduction) -> bool {
342 return TTI.isLegalToVectorizeReduction(Reduction.second, MaxScalableVF);
343 })) {
345 "Scalable vectorization not supported for the reduction "
346 "operations found in this loop.",
347 "ScalableVFUnfeasible", ORE, TheLoop);
348 return false;
349 }
350
351 // Disable scalable vectorization if the loop contains any instructions
352 // with element types not supported for scalable vectors.
353 if (any_of(ElementTypesInLoop, [&](Type *Ty) {
354 return !Ty->isVoidTy() && !TTI.isElementTypeLegalForScalableVector(Ty);
355 })) {
356 reportVectorizationInfo("Scalable vectorization is not supported "
357 "for all element types found in this loop.",
358 "ScalableVFUnfeasible", ORE, TheLoop);
359 return false;
360 }
361
362 if (!Legal->isSafeForAnyVectorWidth() && !getMaxVScale(F, TTI)) {
363 reportVectorizationInfo("The target does not provide maximum vscale value "
364 "for safe distance analysis.",
365 "ScalableVFUnfeasible", ORE, TheLoop);
366 return false;
367 }
368
369 IsScalableVectorizationAllowed = true;
370 return true;
371}
372
374VFSelectionContext::getMaxLegalScalableVF(unsigned MaxSafeElements) {
375 if (!isScalableVectorizationAllowed())
377
378 auto MaxScalableVF = ElementCount::getScalable(
379 std::numeric_limits<ElementCount::ScalarTy>::max());
380 if (Legal->isSafeForAnyVectorWidth())
381 return MaxScalableVF;
382
383 std::optional<unsigned> MaxVScale = getMaxVScale(F, TTI);
384 // Limit MaxScalableVF by the maximum safe dependence distance.
385 MaxScalableVF = ElementCount::getScalable(MaxSafeElements / *MaxVScale);
386
387 if (!MaxScalableVF)
389 "Max legal vector width too small, scalable vectorization "
390 "unfeasible.",
391 "ScalableVFUnfeasible", ORE, TheLoop);
392
393 return MaxScalableVF;
394}
395
397 unsigned MaxTripCount, ElementCount UserVF, unsigned UserIC,
398 bool FoldTailByMasking, bool RequiresScalarEpilogue) {
399 auto [SmallestType, WidestType] = getSmallestAndWidestTypes();
400
401 // Get the maximum safe dependence distance in bits computed by LAA.
402 // It is computed by MaxVF * sizeOf(type) * 8, where type is taken from
403 // the memory accesses that is most restrictive (involved in the smallest
404 // dependence distance).
405 unsigned MaxSafeElementsPowerOf2 =
406 llvm::bit_floor(Legal->getMaxSafeVectorWidthInBits() / WidestType);
407 if (!Legal->isSafeForAnyStoreLoadForwardDistances()) {
408 unsigned SLDist = Legal->getMaxStoreLoadForwardSafeDistanceInBits();
409 MaxSafeElementsPowerOf2 =
410 std::min(MaxSafeElementsPowerOf2, SLDist / WidestType);
411 }
412
413 auto MaxSafeFixedVF = ElementCount::getFixed(MaxSafeElementsPowerOf2);
414 auto MaxSafeScalableVF = getMaxLegalScalableVF(MaxSafeElementsPowerOf2);
415
416 if (!Legal->isSafeForAnyVectorWidth())
417 MaxSafeElements = MaxSafeElementsPowerOf2;
418
419 LLVM_DEBUG(dbgs() << "LV: The max safe fixed VF is: " << MaxSafeFixedVF
420 << ".\n");
421 LLVM_DEBUG(dbgs() << "LV: The max safe scalable VF is: " << MaxSafeScalableVF
422 << ".\n");
423
424 // First analyze the UserVF, fall back if the UserVF should be ignored.
425 if (UserVF) {
426 auto MaxSafeUserVF =
427 UserVF.isScalable() ? MaxSafeScalableVF : MaxSafeFixedVF;
428
429 if (ElementCount::isKnownLE(UserVF, MaxSafeUserVF)) {
430 // If `VF=vscale x N` is safe, then so is `VF=N`
431 if (UserVF.isScalable())
432 return FixedScalableVFPair(
433 ElementCount::getFixed(UserVF.getKnownMinValue()), UserVF);
434
435 return UserVF;
436 }
437
438 assert(ElementCount::isKnownGT(UserVF, MaxSafeUserVF));
439
440 // Only clamp if the UserVF is not scalable. If the UserVF is scalable, it
441 // is better to ignore the hint and let the compiler choose a suitable VF.
442 if (!UserVF.isScalable()) {
443 LLVM_DEBUG(dbgs() << "LV: User VF=" << UserVF
444 << " is unsafe, clamping to max safe VF="
445 << MaxSafeFixedVF << ".\n");
446 ORE->emit([&]() {
447 return OptimizationRemarkAnalysis(DEBUG_TYPE, "VectorizationFactor",
448 TheLoop->getStartLoc(),
449 TheLoop->getHeader())
450 << "User-specified vectorization factor "
451 << ore::NV("UserVectorizationFactor", UserVF)
452 << " is unsafe, clamping to maximum safe vectorization factor "
453 << ore::NV("VectorizationFactor", MaxSafeFixedVF);
454 });
455 return MaxSafeFixedVF;
456 }
457
459 LLVM_DEBUG(dbgs() << "LV: User VF=" << UserVF
460 << " is ignored because scalable vectors are not "
461 "available.\n");
462 ORE->emit([&]() {
463 return OptimizationRemarkAnalysis(DEBUG_TYPE, "VectorizationFactor",
464 TheLoop->getStartLoc(),
465 TheLoop->getHeader())
466 << "User-specified vectorization factor "
467 << ore::NV("UserVectorizationFactor", UserVF)
468 << " is ignored because the target does not support scalable "
469 "vectors. The compiler will pick a more suitable value.";
470 });
471 } else {
472 LLVM_DEBUG(dbgs() << "LV: User VF=" << UserVF
473 << " is unsafe. Ignoring scalable UserVF.\n");
474 ORE->emit([&]() {
475 return OptimizationRemarkAnalysis(DEBUG_TYPE, "VectorizationFactor",
476 TheLoop->getStartLoc(),
477 TheLoop->getHeader())
478 << "User-specified vectorization factor "
479 << ore::NV("UserVectorizationFactor", UserVF)
480 << " is unsafe. Ignoring the hint to let the compiler pick a "
481 "more suitable value.";
482 });
483 }
484 }
485
486 LLVM_DEBUG(dbgs() << "LV: The Smallest and Widest types: " << SmallestType
487 << " / " << WidestType << " bits.\n");
488
491 if (auto MaxVF = getMaximizedVFForTarget(
492 MaxTripCount, SmallestType, WidestType, MaxSafeFixedVF, UserIC,
493 FoldTailByMasking, RequiresScalarEpilogue))
494 Result.FixedVF = MaxVF;
495
496 if (auto MaxVF = getMaximizedVFForTarget(
497 MaxTripCount, SmallestType, WidestType, MaxSafeScalableVF, UserIC,
498 FoldTailByMasking, RequiresScalarEpilogue))
499 if (MaxVF.isScalable()) {
500 Result.ScalableVF = MaxVF;
501 LLVM_DEBUG(dbgs() << "LV: Found feasible scalable VF = " << MaxVF
502 << "\n");
503 }
504
505 return Result;
506}
507
508std::pair<unsigned, unsigned>
510 unsigned MinWidth = -1U;
511 unsigned MaxWidth = 8;
512 const DataLayout &DL = F.getDataLayout();
513 // For in-loop reductions, no element types are added to ElementTypesInLoop
514 // if there are no loads/stores in the loop. In this case, check through the
515 // reduction variables to determine the maximum width.
516 if (ElementTypesInLoop.empty() && !Legal->getReductionVars().empty()) {
517 for (const auto &[_, RdxDesc] : Legal->getReductionVars()) {
518 // When finding the min width used by the recurrence we need to account
519 // for casts on the input operands of the recurrence.
520 MinWidth = std::min(
521 MinWidth,
522 std::min(RdxDesc.getMinWidthCastToRecurrenceTypeInBits(),
523 RdxDesc.getRecurrenceType()->getScalarSizeInBits()));
524 MaxWidth = std::max(MaxWidth,
525 RdxDesc.getRecurrenceType()->getScalarSizeInBits());
526 }
527 } else {
528 for (Type *T : ElementTypesInLoop) {
529 MinWidth = std::min<unsigned>(
530 MinWidth, DL.getTypeSizeInBits(T->getScalarType()).getFixedValue());
531 MaxWidth = std::max<unsigned>(
532 MaxWidth, DL.getTypeSizeInBits(T->getScalarType()).getFixedValue());
533 }
534 }
535
536 // If the loop has no loads/stores or reductions (e.g. a search loop with an
537 // early exit), MinWidth is never updated and is left at its sentinel value.
538 // Fall back to MaxWidth to keep the SmallestType <= WidestType invariant, so
539 // callers such as the max-bandwidth VF computation don't divide by the
540 // sentinel and collapse the VF to zero.
541 if (MinWidth == -1U)
542 MinWidth = MaxWidth;
543
544 return {MinWidth, MaxWidth};
545}
546
548 const SmallPtrSetImpl<const Value *> *ValuesToIgnore) {
549 ElementTypesInLoop.clear();
550 // For each block.
551 for (BasicBlock *BB : TheLoop->blocks()) {
552 // For each instruction in the loop.
553 for (Instruction &I : *BB) {
554 Type *T = I.getType();
555
556 // Skip ignored values.
557 if (ValuesToIgnore && ValuesToIgnore->contains(&I))
558 continue;
559
560 // Only examine Loads, Stores and PHINodes.
562 continue;
563
564 // Examine PHI nodes that are reduction variables. Update the type to
565 // account for the recurrence type.
566 if (auto *PN = dyn_cast<PHINode>(&I)) {
567 if (!Legal->isReductionVariable(PN))
568 continue;
569 const RecurrenceDescriptor &RdxDesc =
570 Legal->getRecurrenceDescriptor(PN);
572 TTI.preferInLoopReduction(RdxDesc.getRecurrenceKind(),
573 RdxDesc.getRecurrenceType()))
574 continue;
575 T = RdxDesc.getRecurrenceType();
576 }
577
578 // Examine the stored values.
579 if (auto *ST = dyn_cast<StoreInst>(&I))
580 T = ST->getValueOperand()->getType();
581
582 assert(T->isSized() &&
583 "Expected the load/store/recurrence type to be sized");
584
585 ElementTypesInLoop.insert(T);
586 }
587 }
588}
589
590void VFSelectionContext::initializeVScaleForTuning() {
592 return;
593
594 if (F.hasFnAttribute(Attribute::VScaleRange)) {
595 auto Attr = F.getFnAttribute(Attribute::VScaleRange);
596 auto Min = Attr.getVScaleRangeMin();
597 auto Max = Attr.getVScaleRangeMax();
598 if (Max && Min == Max) {
599 VScaleForTuning = Max;
600 return;
601 }
602 }
603
604 VScaleForTuning = TTI.getVScaleForTuning();
605}
606
608 const RecurrenceDescriptor &RdxDesc) const {
609 return !Hints->allowReordering() && RdxDesc.isOrdered();
610}
611
613 LLVM_DEBUG(dbgs() << "LV: Performing code size checks.\n");
614
615 Loop *L = const_cast<Loop *>(TheLoop);
616 if (Legal->getRuntimePointerChecking()->Need) {
618 "Runtime ptr check is required with -Os/-Oz",
619 "runtime pointer checks needed. Enable vectorization of this "
620 "loop with '#pragma clang loop vectorize(enable)' when "
621 "compiling with -Os/-Oz",
622 "CantVersionLoopWithOptForSize", ORE, L);
623 return true;
624 }
625
626 if (!PSE.getPredicate().isAlwaysTrue()) {
628 "Runtime SCEV check is required with -Os/-Oz",
629 "runtime SCEV checks needed. Enable vectorization of this "
630 "loop with '#pragma clang loop vectorize(enable)' when "
631 "compiling with -Os/-Oz",
632 "CantVersionLoopWithOptForSize", ORE, L);
633 return true;
634 }
635
636 // FIXME: Avoid specializing for stride==1 instead of bailing out.
637 if (!Legal->getLAI()->getSymbolicStrides().empty()) {
639 "Runtime stride check for small trip count",
640 "runtime stride == 1 checks needed. Enable vectorization of "
641 "this loop without such check by compiling with -Os/-Oz",
642 "CantVersionLoopWithOptForSize", ORE, L);
643 return true;
644 }
645
646 return false;
647}
648
650 MinBWs = computeMinimumValueSizes(TheLoop->getBlocks(), *DB, &TTI);
651}
652
654 // Avoid duplicating work finding in-loop reductions.
655 if (!InLoopReductions.empty())
656 return;
657
658 for (const auto &Reduction : Legal->getReductionVars()) {
659 PHINode *Phi = Reduction.first;
660 const RecurrenceDescriptor &RdxDesc = Reduction.second;
661
662 // Multi-use reductions (e.g., used in FindLastIV patterns) are handled
663 // separately and should not be considered for in-loop reductions.
664 if (RdxDesc.hasUsesOutsideReductionChain())
665 continue;
666
667 // We don't collect reductions that are type promoted (yet).
668 if (RdxDesc.getRecurrenceType() != Phi->getType())
669 continue;
670
671 // In-loop AnyOf and FindIV reductions are not yet supported.
672 RecurKind Kind = RdxDesc.getRecurrenceKind();
676 continue;
677
678 // If the target would prefer this reduction to happen "in-loop", then we
679 // want to record it as such.
681 !TTI.preferInLoopReduction(Kind, Phi->getType()))
682 continue;
683
684 // Check that we can correctly put the reductions into the loop, by
685 // finding the chain of operations that leads from the phi to the loop
686 // exit value.
687 SmallVector<Instruction *, 4> ReductionOperations =
688 RdxDesc.getReductionOpChain(Phi, const_cast<Loop *>(TheLoop));
689 bool InLoop = !ReductionOperations.empty();
690
691 if (InLoop) {
692 InLoopReductions.insert(Phi);
693 // Add the elements to InLoopReductionImmediateChains for cost modelling.
694 Instruction *LastChain = Phi;
695 for (auto *I : ReductionOperations) {
696 InLoopReductionImmediateChains[I] = LastChain;
697 LastChain = I;
698 }
699 }
700 LLVM_DEBUG(dbgs() << "LV: Using " << (InLoop ? "inloop" : "out of loop")
701 << " reduction for phi: " << *Phi << "\n");
702 }
703}
704
705bool LoopVectorizationPlanner::isMoreProfitable(const VectorizationFactor &A,
706 const VectorizationFactor &B,
707 const unsigned MaxTripCount,
708 bool HasTail,
709 bool IsEpilogue) const {
710 InstructionCost CostA = A.Cost;
711 InstructionCost CostB = B.Cost;
712
713 // When there is a hint to always prefer scalable vectors, honour that hint.
715 if (A.Width.isScalable() && CostA.isValid() && !B.Width.isScalable() &&
716 !B.Width.isScalar())
717 return true;
718
719 // Favor fixed VFs for epilogue loops by scaling the costs of scalable VFs
720 // 'ScalableEpilogueVFCostScaleFactor' (default 2.0). This is intended to
721 // model that fixed VFs are more likely to be fully unrolled (or optimized
722 // out) post vectorization. TODO: Reconsider this restriction for predicated
723 // epilogues (once supported).
724 if (IsEpilogue && A.Width.isScalable() != B.Width.isScalable() &&
725 A.Cost.isValid() && B.Cost.isValid()) {
726 auto [FixedCost, ScalableCost] = std::make_pair(CostA, CostB);
727 if (B.Width.isFixed())
728 std::swap(FixedCost, ScalableCost);
729
730 ScalableCost *= ScalableEpilogueVFCostScaleFactor;
731
732 if (FixedCost <= ScalableCost)
733 return A.Width.isFixed();
734 }
735
736 // Improve estimate for the vector width if it is scalable.
737 unsigned EstimatedWidthA = A.Width.getKnownMinValue();
738 unsigned EstimatedWidthB = B.Width.getKnownMinValue();
739 if (std::optional<unsigned> VScale = Config.getVScaleForTuning()) {
740 if (A.Width.isScalable())
741 EstimatedWidthA *= *VScale;
742 if (B.Width.isScalable())
743 EstimatedWidthB *= *VScale;
744 }
745
746 // When optimizing for size choose whichever is smallest, which will be the
747 // one with the smallest cost for the whole loop. On a tie pick the larger
748 // vector width, on the assumption that throughput will be greater.
749 if (Config.CostKind == TTI::TCK_CodeSize)
750 return CostA < CostB ||
751 (CostA == CostB && EstimatedWidthA > EstimatedWidthB);
752
753 // Assume vscale may be larger than 1 (or the value being tuned for),
754 // so that scalable vectorization is slightly favorable over fixed-width
755 // vectorization.
756 bool PreferScalable = !TTI.preferFixedOverScalableIfEqualCost() &&
757 A.Width.isScalable() && !B.Width.isScalable();
758
759 auto CmpFn = [PreferScalable](const InstructionCost &LHS,
760 const InstructionCost &RHS) {
761 return PreferScalable ? LHS <= RHS : LHS < RHS;
762 };
763
764 // To avoid the need for FP division:
765 // (CostA / EstimatedWidthA) < (CostB / EstimatedWidthB)
766 // <=> (CostA * EstimatedWidthB) < (CostB * EstimatedWidthA)
767 bool LowerCostWithoutTC =
768 CmpFn(CostA * EstimatedWidthB, CostB * EstimatedWidthA);
769 if (!MaxTripCount)
770 return LowerCostWithoutTC;
771
772 auto GetCostForTC = [MaxTripCount, HasTail](unsigned VF,
773 InstructionCost VectorCost,
774 InstructionCost ScalarCost) {
775 // If the trip count is a known (possibly small) constant, the trip count
776 // will be rounded up to an integer number of iterations under
777 // FoldTailByMasking. The total cost in that case will be
778 // VecCost*ceil(TripCount/VF). When not folding the tail, the total
779 // cost will be VecCost*floor(TC/VF) + ScalarCost*(TC%VF). There will be
780 // some extra overheads, but for the purpose of comparing the costs of
781 // different VFs we can use this to compare the total loop-body cost
782 // expected after vectorization.
783 if (HasTail)
784 return VectorCost * (MaxTripCount / VF) +
785 ScalarCost * (MaxTripCount % VF);
786 return VectorCost * divideCeil(MaxTripCount, VF);
787 };
788
789 auto RTCostA = GetCostForTC(EstimatedWidthA, CostA, A.ScalarCost);
790 auto RTCostB = GetCostForTC(EstimatedWidthB, CostB, B.ScalarCost);
791 bool LowerCostWithTC = CmpFn(RTCostA, RTCostB);
792 LLVM_DEBUG(if (LowerCostWithTC != LowerCostWithoutTC) {
793 dbgs() << "LV: VF " << (LowerCostWithTC ? A.Width : B.Width)
794 << " has lower cost than VF "
795 << (LowerCostWithTC ? B.Width : A.Width)
796 << " when taking the cost of the remaining scalar loop iterations "
797 "into consideration for a maximum trip count of "
798 << MaxTripCount << ".\n";
799 });
800 return LowerCostWithTC;
801}
802
803bool LoopVectorizationPlanner::isMoreProfitable(const VectorizationFactor &A,
804 const VectorizationFactor &B,
805 bool HasTail,
806 bool IsEpilogue) const {
807 const unsigned MaxTripCount = PSE.getSmallConstantMaxTripCount();
808 return LoopVectorizationPlanner::isMoreProfitable(A, B, MaxTripCount, HasTail,
809 IsEpilogue);
810}
811
812// TODO: we could return a pair of values that specify the max VF and
813// min VF, to be used in `buildVPlans(MinVF, MaxVF)` instead of
814// `buildVPlans(VF, VF)`. We cannot do it because VPLAN at the moment
815// doesn't have a cost model that can choose which plan to execute if
816// more than one is generated.
819 if (UserVF.isScalable() && !supportsScalableVectors()) {
821 "Scalable vectorization requested but not supported by the target",
822 "the scalable user-specified vectorization width for outer-loop "
823 "vectorization cannot be used because the target does not support "
824 "scalable vectors.",
825 "ScalableVFUnfeasible", ORE, TheLoop);
827 }
828
829 ElementCount VF = UserVF;
830 if (VF.isZero()) {
831 auto [_, WidestType] = getSmallestAndWidestTypes();
832
833 auto RegKind = TTI.enableScalableVectorization()
836
837 TypeSize RegSize = TTI.getRegisterBitWidth(RegKind);
838 // The widest type may be wider than the register width and WidestType may
839 // not be a power of two; round the element count down to a power of two.
840 unsigned N = std::max<uint64_t>(
841 1, llvm::bit_floor(RegSize.getKnownMinValue() / WidestType));
842 VF = ElementCount::get(N, RegSize.isScalable());
843 LLVM_DEBUG(dbgs() << "LV: VPlan computed VF " << VF << ".\n");
844
845 // Make sure we have a VF > 1 for stress testing.
847 LLVM_DEBUG(dbgs() << "LV: VPlan stress testing: "
848 << "overriding computed VF.\n");
850 }
851 }
853 "VF needs to be a power of two");
854 if (VF.isScalar())
856 LLVM_DEBUG(dbgs() << "LV: Using " << (!UserVF.isZero() ? "user " : "")
857 << "VF " << VF << " to build VPlans.\n");
858 return FixedScalableVFPair(VF);
859}
860
861/// \returns true if the VPlan contains header phi recipes that are not
862/// currently supported for epilogue vectorization.
864 return any_of(
866 [](VPRecipeBase &R) {
867 switch (R.getVPRecipeID()) {
868 case VPRecipeBase::VPFirstOrderRecurrencePHISC:
869 // TODO: Add support for fixed-order recurrences.
870 return true;
871 case VPRecipeBase::VPWidenIntOrFpInductionSC:
872 return !cast<VPWidenIntOrFpInductionRecipe>(&R)->getPHINode();
873 case VPRecipeBase::VPReductionPHISC: {
874 auto *RedPhi = cast<VPReductionPHIRecipe>(&R);
875 // TODO: Support FMinNum/FMaxNum, FindLast reductions, and reductions
876 // without underlying values.
877 RecurKind Kind = RedPhi->getRecurrenceKind();
878 if (RecurrenceDescriptor::isFPMinMaxNumRecurrenceKind(Kind) ||
879 RecurrenceDescriptor::isFindLastRecurrenceKind(Kind) ||
880 !RedPhi->getUnderlyingValue())
881 return true;
882 // TODO: Add support for FindIV reductions with sunk expressions: the
883 // resume value from the main loop is in expression domain (e.g.,
884 // mul(ReducedIV, 3)), but the epilogue tracks raw IV values. A sunk
885 // expression is identified by a non-VPInstruction user of
886 // ComputeReductionResult.
887 if (RecurrenceDescriptor::isFindIVRecurrenceKind(Kind)) {
888 auto *RdxResult = vputils::findComputeReductionResult(RedPhi);
889 assert(RdxResult &&
890 "FindIV reduction must have ComputeReductionResult");
891 return any_of(RdxResult->users(),
892 std::not_fn(IsaPred<VPInstruction>));
893 }
894 return false;
895 }
896 default:
897 return false;
898 };
899 });
900}
901
902bool LoopVectorizationPlanner::isCandidateForEpilogueVectorization(
903 VPlan &MainPlan) const {
904 // Bail out if the plan contains header phi recipes not yet supported
905 // for epilogue vectorization.
906 if (hasUnsupportedHeaderPhiRecipe(MainPlan))
907 return false;
908
909 // Epilogue vectorization code has not been auditted to ensure it handles
910 // non-latch exits properly. It may be fine, but it needs auditted and
911 // tested.
912 // TODO: Add support for loops with an early exit.
913 if (OrigLoop->getExitingBlock() != OrigLoop->getLoopLatch())
914 return false;
915
916 return true;
917}
unsigned RegSize
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define DEBUG_TYPE
#define _
loop Loop Strength Reduction
This file defines the LoopVectorizationLegality class.
static cl::opt< float > ScalableEpilogueVFCostScaleFactor("scalable-epilogue-vf-cost-scale-factor", cl::init(2.0), cl::Hidden, cl::desc("Scale the cost of scalable epilogue VFs by this factor."))
static bool hasUnsupportedHeaderPhiRecipe(VPlan &Plan)
static void debugVectorizationMessage(const StringRef Prefix, const StringRef DebugMsg, Instruction *I)
Write a DebugMsg about vectorization to the debug output stream.
static cl::opt< bool > ForceTargetSupportsGatherScatterOps("force-target-supports-gather-scatter-ops", cl::init(false), cl::Hidden, cl::desc("Assume the target supports gather/scatter operations (used for " "testing)."))
cl::opt< bool > VPlanBuildOuterloopStressTest
static cl::opt< bool > ForceTargetSupportsScalableVectors("force-target-supports-scalable-vectors", cl::init(false), cl::Hidden, cl::desc("Pretend that scalable vectors are supported, even if the target does " "not support them. This flag should only be used for testing."))
static cl::opt< bool > ConsiderRegPressure("vectorizer-consider-reg-pressure", cl::init(false), cl::Hidden, cl::desc("Discard VFs if their register pressure is too high."))
static cl::opt< bool > UseWiderVFIfCallVariantsPresent("vectorizer-maximize-bandwidth-for-vector-calls", cl::init(true), cl::Hidden, cl::desc("Try wider VFs if they enable the use of vector variants"))
static OptimizationRemarkAnalysis createLVAnalysis(StringRef RemarkName, const Loop *TheLoop, Instruction *I, DebugLoc DL={})
Create an analysis remark that explains why vectorization failed RemarkName is the identifier for the...
static cl::opt< bool > ForceTargetSupportsMaskedMemoryOps("force-target-supports-masked-memory-ops", cl::init(false), cl::Hidden, cl::desc("Assume the target supports masked memory operations (used for " "testing)."))
Note: This currently only applies to llvm.masked.load and llvm.masked.store.
static cl::opt< bool > MaximizeBandwidth("vectorizer-maximize-bandwidth", cl::init(false), cl::Hidden, cl::desc("Maximize bandwidth when selecting vectorization factor which " "will be determined by the smallest type in loop."))
This file provides a LoopVectorizationPlanner class.
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
#define T
const char * Msg
#define LLVM_DEBUG(...)
Definition Debug.h:119
Value * RHS
Value * LHS
LLVM Basic Block Representation.
Definition BasicBlock.h:62
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
A debug info location.
Definition DebugLoc.h:126
constexpr bool isVector() const
One or more elements.
Definition TypeSize.h:324
static constexpr ElementCount getScalable(ScalarTy MinVal)
Definition TypeSize.h:312
static constexpr ElementCount getFixed(ScalarTy MinVal)
Definition TypeSize.h:309
static constexpr ElementCount get(ScalarTy MinVal, bool Scalable)
Definition TypeSize.h:315
constexpr bool isScalar() const
Exactly one element.
Definition TypeSize.h:320
bool isInnermost() const
Return true if the loop does not contain any (natural) loops.
BlockT * getHeader() const
bool hasVectorCallVariants() const
Returns true if there is at least one function call in the loop which has a vectorized variant availa...
Represents a single loop in the control flow graph.
Definition LoopInfo.h:40
DebugLoc getStartLoc() const
Return the debug location of the start of this loop.
Definition LoopInfo.cpp:695
Diagnostic information for optimization analysis remarks.
The optimization diagnostic interface.
LLVM_ABI void emit(DiagnosticInfoOptimizationBase &OptDiag)
Output the remark via the diagnostic handler and to the optimization record file.
Diagnostic information for applied optimization remarks.
The RecurrenceDescriptor is used to identify recurrences variables in a loop.
Type * getRecurrenceType() const
Returns the type of the recurrence.
bool hasUsesOutsideReductionChain() const
Returns true if the reduction PHI has any uses outside the reduction chain.
static bool isFindLastRecurrenceKind(RecurKind Kind)
Returns true if the recurrence kind is of the form select(cmp(),x,y) where one of (x,...
LLVM_ABI SmallVector< Instruction *, 4 > getReductionOpChain(PHINode *Phi, Loop *L) const
Attempts to find a chain of operations from Phi to LoopExitInst that can be treated as a set of reduc...
static bool isAnyOfRecurrenceKind(RecurKind Kind)
Returns true if the recurrence kind is of the form select(cmp(),x,y) where one of (x,...
RecurKind getRecurrenceKind() const
bool isOrdered() const
Expose an ordered FP reduction to the instance users.
static bool isFindIVRecurrenceKind(RecurKind Kind)
Returns true if the recurrence kind is of the form select(cmp(),x,y) where one of (x,...
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
bool contains(ConstPtrType Ptr) const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
@ TCK_CodeSize
Instruction code size.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
bool isVoidTy() const
Return true if this is 'void'.
Definition Type.h:141
FixedScalableVFPair computeVPlanOuterloopVF(ElementCount UserVF)
Returns a scalable VF to use for outer-loop vectorization if the target supports it and a fixed VF ot...
std::pair< unsigned, unsigned > getSmallestAndWidestTypes() const
bool runtimeChecksRequired()
Check whether vectorization would require runtime checks.
bool isLegalGatherOrScatter(Value *V, ElementCount VF) const
Returns true if the target machine can represent V as a masked gather or scatter operation.
bool isLegalMaskedLoadOrStore(bool IsLoad, Type *ScalarTy, Align Alignment, unsigned AddressSpace) const
Returns true if the target machine supports a masked load (if IsLoad) or masked store of scalar type ...
void collectInLoopReductions()
Split reductions into those that happen in the loop, and those that happen outside.
FixedScalableVFPair computeFeasibleMaxVF(unsigned MaxTripCount, ElementCount UserVF, unsigned UserIC, bool FoldTailByMasking, bool RequiresScalarEpilogue)
const LoopVectorizeHints & getHints() const
bool useOrderedReductions(const RecurrenceDescriptor &RdxDesc) const
Returns true if we should use strict in-order reductions for the given RdxDesc.
bool shouldConsiderRegPressureForVF(ElementCount VF) const
void collectElementTypesForWidening(const SmallPtrSetImpl< const Value * > *ValuesToIgnore=nullptr)
Collect element types in the loop that need widening.
std::optional< unsigned > getVScaleForTuning() const
void computeMinimalBitwidths()
Compute smallest bitwidth each instruction can be represented with.
iterator_range< iterator > phis()
Returns an iterator range over the PHI-like recipes in the block.
Definition VPlan.h:4488
const VPBasicBlock * getEntryBasicBlock() const
Definition VPlan.cpp:216
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
Definition VPlan.h:410
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
Definition VPlan.h:4812
LLVM_ABI_FOR_TEST VPRegionBlock * getVectorLoopRegion()
Returns the VPRegionBlock of the vector loop.
Definition VPlan.cpp:1080
LLVM Value Representation.
Definition Value.h:75
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
static constexpr bool isKnownLE(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
Definition TypeSize.h:230
static constexpr bool isKnownLT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
Definition TypeSize.h:216
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
Definition TypeSize.h:168
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
Definition TypeSize.h:165
constexpr bool isZero() const
Definition TypeSize.h:153
static constexpr bool isKnownGT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
Definition TypeSize.h:223
void reportVectorizationFailure(const StringRef DebugMsg, const StringRef OREMsg, const StringRef ORETag, OptimizationRemarkEmitter *ORE, const Loop *TheLoop, Instruction *I=nullptr)
Reports a vectorization failure: print DebugMsg for debugging purposes along with the corresponding o...
void reportVectorizationInfo(const StringRef Msg, const StringRef ORETag, OptimizationRemarkEmitter *ORE, const Loop *TheLoop, Instruction *I=nullptr, DebugLoc DL={})
Reports an informative message: print Msg for debugging purposes as well as an optimization remark.
void reportVectorization(OptimizationRemarkEmitter *ORE, Loop *TheLoop, ElementCount VFWidth, unsigned IC)
Report successful vectorization of the loop.
initializer< Ty > init(const Ty &Val)
DiagnosticInfoOptimizationBase::Argument NV
This is an optimization pass for GlobalISel generic memory operations.
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
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
Align getLoadStoreAlignment(const Value *I)
A helper function that returns the alignment of load or store instruction.
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:1746
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Definition MathExtras.h:280
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
std::optional< unsigned > getMaxVScale(const Function &F, const TargetTransformInfo &TTI)
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
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
Definition MathExtras.h:389
TargetTransformInfo TTI
RecurKind
These are the kinds of recurrences that we support.
Type * getLoadStoreType(const Value *I)
A helper function that returns the type of a load or store instruction.
T bit_floor(T Value)
Returns the largest integral power of two no greater than Value if Value is nonzero.
Definition bit.h:347
LLVM_ABI MapVector< Instruction *, uint64_t > computeMinimumValueSizes(ArrayRef< BasicBlock * > Blocks, DemandedBits &DB, const TargetTransformInfo *TTI=nullptr)
Compute a map of integer instructions to their minimum legal type size.
cl::opt< bool > PreferInLoopReductions
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition BitVector.h:880
#define N
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
A class that represents two vectorization factors (initialized with 0 by default).
static FixedScalableVFPair getNone()
TODO: The following VectorizationFactor was pulled out of LoopVectorizationCostModel class.
static LLVM_ABI ElementCount VectorizationFactor
VF as overridden by the user.