LLVM 22.0.0git
VectorSlice Class Reference

Helper class for "break large PHIs" (visitPHINode). More...

Public Member Functions

 VectorSlice (Type *Ty, unsigned Idx, unsigned NumElts)
ValuegetSlicedVal (BasicBlock *BB, Value *Inc, StringRef NewValName)
 Slice Inc according to the information contained within this slice.

Public Attributes

TypeTy = nullptr
unsigned Idx = 0
unsigned NumElts = 0
PHINodeNewPHI = nullptr

Detailed Description

Helper class for "break large PHIs" (visitPHINode).

This represents a slice of a PHI's incoming value, which is made up of:

  • The type of the slice (Ty)
  • The index in the incoming value's vector where the slice starts (Idx)
  • The number of elements in the slice (NumElts). It also keeps track of the NewPHI node inserted for this particular slice.

Slice examples: <4 x i64> -> Split into four i64 slices. -> [i64, 0, 1], [i64, 1, 1], [i64, 2, 1], [i64, 3, 1] <5 x i16> -> Split into 2 <2 x i16> slices + a i16 tail. -> [<2 x i16>, 0, 2], [<2 x i16>, 2, 2], [i16, 4, 1]

Definition at line 1692 of file AMDGPUCodeGenPrepare.cpp.

Constructor & Destructor Documentation

◆ VectorSlice()

VectorSlice::VectorSlice ( Type * Ty,
unsigned Idx,
unsigned NumElts )
inline

Definition at line 1694 of file AMDGPUCodeGenPrepare.cpp.

References Idx, NumElts, and Ty.

Member Function Documentation

◆ getSlicedVal()

Value * VectorSlice::getSlicedVal ( BasicBlock * BB,
Value * Inc,
StringRef NewValName )
inline

Slice Inc according to the information contained within this slice.

This is cached, so if called multiple times for the same BB & Inc pair, it returns the same Sliced value as well.

Note this intentionally does not return the same value for, say, [bb.0, %0] & [bb.1, %0] as:

  • It could cause issues with dominance (e.g. if bb.1 is seen first, then the value in bb.1 may not be reachable from bb.0 if it's its predecessor.)
  • We also want to make our extract instructions as local as possible so the DAG has better chances of folding them out. Duplicating them like that is beneficial in that regard.

This is both a minor optimization to avoid creating duplicate instructions, but also a requirement for correctness. It is not forbidden for a PHI node to have the same [BB, Val] pair multiple times. If we returned a new value each time, those previously identical pairs would all have different incoming values (from the same block) and it'd cause a "PHI node has multiple entries for the same basic block with different incoming values!" verifier error.

Definition at line 1722 of file AMDGPUCodeGenPrepare.cpp.

References B(), llvm::dyn_cast(), llvm::BasicBlock::getTerminator(), Idx, and NumElts.

Member Data Documentation

◆ Idx

unsigned VectorSlice::Idx = 0

Definition at line 1698 of file AMDGPUCodeGenPrepare.cpp.

Referenced by getSlicedVal(), and VectorSlice().

◆ NewPHI

PHINode* VectorSlice::NewPHI = nullptr

Definition at line 1700 of file AMDGPUCodeGenPrepare.cpp.

◆ NumElts

unsigned VectorSlice::NumElts = 0

Definition at line 1699 of file AMDGPUCodeGenPrepare.cpp.

Referenced by getSlicedVal(), and VectorSlice().

◆ Ty

Type* VectorSlice::Ty = nullptr

Definition at line 1697 of file AMDGPUCodeGenPrepare.cpp.

Referenced by VectorSlice().


The documentation for this class was generated from the following file: