LLVM: lib/Transforms/Vectorize/VPlanUtils.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_TRANSFORMS_VECTORIZE_VPLANUTILS_H

10#define LLVM_TRANSFORMS_VECTORIZE_VPLANUTILS_H

11

14

15namespace llvm {

19}

20

21namespace llvm {

22

24

26

27

29

30

32

33

34

35

36

37

39

40

41

43 const Loop *L = nullptr);

44

45

46

48

49

51

52

53

54

55

57

58

59

61

62

63

65

66

67

68

69

70

71

73std::optional<VPValue *>

77

78

79

80

82

83

84

87 return ID.getInductionBinOp()->getFastMathFlags();

88

90 ID.getInductionBinOp()))

92 OBO->hasNoSignedWrap());

93

95 "Expected int induction");

97}

98}

99

100

101

102

103

104

106public:

108

109

110

111

112

113

117 "Can't insert new block with predecessors or successors.");

121 Succ->replacePredecessor(BlockPtr, NewBlock);

122 NewBlock->appendSuccessor(Succ);

123 }

126 }

127

128

129

130

131

135 "Can't insert new block with predecessors or successors.");

138 Pred->replaceSuccessor(BlockPtr, NewBlock);

139 NewBlock->appendPredecessor(Pred);

140 }

143 }

144

145

146

147

148

149

150

154 "Can't insert IfTrue with successors.");

156 "Can't insert IfFalse with successors.");

162 }

163

164

165

166

167

168

169

171 unsigned PredIdx = -1u, unsigned SuccIdx = -1u) {

173 "Can't connect two block with different parents");

175 "Blocks can't have more than two successors.");

176 if (SuccIdx == -1u)

177 From->appendSuccessor(To);

178 else

180

181 if (PredIdx == -1u)

182 To->appendPredecessor(From);

183 else

185 }

186

187

188

190 assert(To && "Successor to disconnect is null.");

191 From->removeSuccessor(To);

192 To->removePredecessor(From);

193 }

194

195

196

199 Pred->replaceSuccessor(Old, New);

201 Succ->replacePredecessor(Old, New);

206 }

207

208

209

210 template <typename BlockTy, typename T>

212

213 using BaseTy = std::conditional_t<std::is_const::value,

215

216

217

218 auto Mapped =

224 });

225 }

226

227

228

229

230

231

239

240

241

243

244

246};

247

248}

249

250#endif

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

#define LLVM_ABI_FOR_TEST

std::pair< BasicBlock *, unsigned > BlockTy

A pair of (basic block, score).

ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))

This file contains the declarations of the Vectorization Plan base classes:

A struct for saving information about induction variables.

@ IK_FpInduction

Floating point induction variable.

@ IK_IntInduction

Integer induction variable. Step = C.

Represents a single loop in the control flow graph.

Representation for a specific memory location.

This class represents an analyzed expression in the program.

The main scalar evolution driver.

This class consists of common code factored out of the SmallVector class to reduce code duplication b...

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

VPBasicBlock serves as the leaf of the Hierarchical Control-Flow Graph.

VPBlockBase is the building block of the Hierarchical Control-Flow Graph.

VPRegionBlock * getParent()

iterator_range< VPBlockBase ** > predecessors()

size_t getNumSuccessors() const

iterator_range< VPBlockBase ** > successors()

unsigned getIndexForSuccessor(const VPBlockBase *Succ) const

Returns the index for Succ in the blocks successor list.

void setPredecessors(ArrayRef< VPBlockBase * > NewPreds)

Set each VPBasicBlock in NewPreds as predecessor of this VPBlockBase.

unsigned getIndexForPredecessor(const VPBlockBase *Pred) const

Returns the index for Pred in the blocks predecessors list.

const VPBlocksTy & getPredecessors() const

void clearSuccessors()

Remove all the successors of this block.

void setTwoSuccessors(VPBlockBase *IfTrue, VPBlockBase *IfFalse)

Set two given VPBlockBases IfTrue and IfFalse to be the two successors of this VPBlockBase.

void clearPredecessors()

Remove all the predecessor of this block.

void setParent(VPRegionBlock *P)

const VPBlocksTy & getSuccessors() const

static auto blocksOnly(const T &Range)

Return an iterator range over Range which only includes BlockTy blocks.

Definition VPlanUtils.h:211

static void insertBlockAfter(VPBlockBase *NewBlock, VPBlockBase *BlockPtr)

Insert disconnected VPBlockBase NewBlock after BlockPtr.

Definition VPlanUtils.h:114

static void insertOnEdge(VPBlockBase *From, VPBlockBase *To, VPBlockBase *BlockPtr)

Inserts BlockPtr on the edge between From and To.

Definition VPlanUtils.h:232

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.

static void insertTwoBlocksAfter(VPBlockBase *IfTrue, VPBlockBase *IfFalse, VPBlockBase *BlockPtr)

Insert disconnected VPBlockBases IfTrue and IfFalse after BlockPtr.

Definition VPlanUtils.h:151

static void connectBlocks(VPBlockBase *From, VPBlockBase *To, unsigned PredIdx=-1u, unsigned SuccIdx=-1u)

Connect VPBlockBases From and To bi-directionally.

Definition VPlanUtils.h:170

static void disconnectBlocks(VPBlockBase *From, VPBlockBase *To)

Disconnect VPBlockBases From and To bi-directionally.

Definition VPlanUtils.h:189

static void reassociateBlocks(VPBlockBase *Old, VPBlockBase *New)

Reassociate all the blocks connected to Old so that they now point to New.

Definition VPlanUtils.h:197

static void insertBlockBefore(VPBlockBase *NewBlock, VPBlockBase *BlockPtr)

Insert disconnected block NewBlock before Blockptr.

Definition VPlanUtils.h:132

Template specialization of the standard LLVM dominator tree utility for VPBlockBases.

Class to record and manage LLVM IR flags.

VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.

This is the base class of the VPlan Def/Use graph, used for modeling the data flow into,...

VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

Definition VPlanUtils.h:23

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.

VPIRFlags getFlagsFromIndDesc(const InductionDescriptor &ID)

Extracts and returns NoWrap and FastMath flags from the induction binop in ID.

Definition VPlanUtils.h:85

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 dyn_cast_if_present(const Y &Val)

dyn_cast_if_present - Functionally identical to dyn_cast, except that a null (or none in the case ...

auto map_range(ContainerTy &&C, FuncTy F)

SmallVector< ValueTypeFromRangeType< R >, Size > to_vector(R &&Range)

Given a range of type R, iterate the entire range and return a SmallVector with elements of the vecto...

iterator_range< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)

Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...

bool isa(const From &Val)

isa - Return true if the parameter to the template is an instance of one of the template type argu...

decltype(auto) cast(const From &Val)

cast - Return the argument parameter cast to the specified type.