LLVM 23.0.0git
VPRecipeBuilder.h
Go to the documentation of this file.
1//===- VPRecipeBuilder.h - Helper class to build recipes --------*- 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_VPRECIPEBUILDER_H
10#define LLVM_TRANSFORMS_VECTORIZE_VPRECIPEBUILDER_H
11
13#include "VPlan.h"
15
16namespace llvm {
17
21struct HistogramInfo;
22struct VFRange;
23
24/// Helper class to create VPRecipies from IR instructions.
26 /// The VPlan new recipes are added to.
27 VPlan &Plan;
28
29 /// Target Library Info.
30 const TargetLibraryInfo *TLI;
31
32 /// The legality analysis.
34
35 /// The profitablity analysis.
37
38 VPBuilder &Builder;
39
40 /// Check if \p I can be widened at the start of \p Range and possibly
41 /// decrease the range such that the returned value holds for the entire \p
42 /// Range. The function should not be called for memory instructions or calls.
43 bool shouldWiden(Instruction *I, VFRange &Range) const;
44
45 /// Optimize the special case where the operand of \p VPI is a constant
46 /// integer induction variable.
48 tryToOptimizeInductionTruncate(VPInstruction *VPI, VFRange &Range);
49
50 /// Handle call instructions. If \p VPI can be widened for \p Range.Start,
51 /// return a new VPWidenCallRecipe or VPWidenIntrinsicRecipe. Range.End may be
52 /// decreased to ensure same decision from \p Range.Start to \p Range.End.
53 VPSingleDefRecipe *tryToWidenCall(VPInstruction *VPI, VFRange &Range);
54
55 /// Check if \p VPI has an opcode that can be widened and return a
56 /// VPWidenRecipe if it can. The function should only be called if the
57 /// cost-model indicates that widening should be performed.
58 VPWidenRecipe *tryToWiden(VPInstruction *VPI);
59
60public:
64 : Plan(Plan), TLI(TLI), Legal(Legal), CM(CM), Builder(Builder) {}
65
66 /// Create and return a widened recipe for a non-phi recipe \p R if one can be
67 /// created within the given VF \p Range.
69 VFRange &Range);
70
71 /// Check if the load or store instruction \p VPI should widened for \p
72 /// Range.Start and potentially masked. Such instructions are handled by a
73 /// recipe that takes an additional VPInstruction for the mask.
75
76 /// If \p VPI represents a histogram operation (as determined by
77 /// LoopVectorizationLegality) make that safe for vectorization, by emitting a
78 /// llvm.experimental.vector.histogram.add intrinsic in place of the Load +
79 /// Add|Sub + Store operations that perform the histogram in the original
80 /// scalar loop.
82
83 /// If \p VPI is a store of a reduction into an invariant address, delete it.
84 /// If it is the final store of a reduction result, a uniform store recipe
85 /// will be created for it in the middle block. Returns `true` if replacement
86 /// took place. The order of stores must be preserved, hence \p
87 /// FinalRedStoresBuidler.
89 VPBuilder &FinalRedStoresBuilder);
90
91 /// Build a VPReplicationRecipe for \p VPI. If it is predicated, add the mask
92 /// as last operand. Range.End may be decreased to ensure same recipe behavior
93 /// from \p Range.Start to \p Range.End.
95};
96} // end namespace llvm
97
98#endif // LLVM_TRANSFORMS_VECTORIZE_VPRECIPEBUILDER_H
This file provides a LoopVectorizationPlanner class.
#define I(x, y, z)
Definition MD5.cpp:57
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This file contains the declarations of the Vectorization Plan base classes:
LoopVectorizationCostModel - estimates the expected speedups due to vectorization.
LoopVectorizationLegality checks if it is legal to vectorize a loop, and to what vectorization factor...
Provides information about what library functions are available for the current target.
VPlan-based builder utility analogous to IRBuilder.
A recipe representing a sequence of load -> update -> store as part of a histogram operation.
Definition VPlan.h:2040
This is a concrete Recipe that models a single VPlan-level instruction.
Definition VPlan.h:1222
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
Definition VPlan.h:405
VPRecipeBase * tryToCreateWidenNonPhiRecipe(VPSingleDefRecipe *R, VFRange &Range)
Create and return a widened recipe for a non-phi recipe R if one can be created within the given VF R...
VPHistogramRecipe * widenIfHistogram(VPInstruction *VPI)
If VPI represents a histogram operation (as determined by LoopVectorizationLegality) make that safe f...
VPRecipeBuilder(VPlan &Plan, const TargetLibraryInfo *TLI, LoopVectorizationLegality *Legal, LoopVectorizationCostModel &CM, VPBuilder &Builder)
VPRecipeBase * tryToWidenMemory(VPInstruction *VPI, VFRange &Range)
Check if the load or store instruction VPI should widened for Range.Start and potentially masked.
bool replaceWithFinalIfReductionStore(VPInstruction *VPI, VPBuilder &FinalRedStoresBuilder)
If VPI is a store of a reduction into an invariant address, delete it.
VPReplicateRecipe * handleReplication(VPInstruction *VPI, VFRange &Range)
Build a VPReplicationRecipe for VPI.
VPReplicateRecipe replicates a given instruction producing multiple scalar copies of the original sca...
Definition VPlan.h:3190
VPSingleDef is a base class for recipes for modeling a sequence of one or more output IR that define ...
Definition VPlan.h:605
A recipe for handling phi nodes of integer and floating-point inductions, producing their vector valu...
Definition VPlan.h:2443
VPWidenRecipe is a recipe for producing a widened instruction using the opcode and operands of the re...
Definition VPlan.h:1776
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
Definition VPlan.h:4507
This is an optimization pass for GlobalISel generic memory operations.
This holds details about a histogram operation – a load -> update -> store sequence where each lane i...
A range of powers-of-2 vectorization factors with fixed start and adjustable end.