LLVM 19.0.0git
Public Member Functions | Public Attributes | List of all members
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:

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 1883 of file AMDGPUCodeGenPrepare.cpp.

Constructor & Destructor Documentation

◆ VectorSlice()

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

Definition at line 1885 of file AMDGPUCodeGenPrepare.cpp.

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 1913 of file AMDGPUCodeGenPrepare.cpp.

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

Member Data Documentation

◆ Idx

unsigned VectorSlice::Idx = 0

Definition at line 1889 of file AMDGPUCodeGenPrepare.cpp.

Referenced by getSlicedVal().

◆ NewPHI

PHINode* VectorSlice::NewPHI = nullptr

Definition at line 1891 of file AMDGPUCodeGenPrepare.cpp.

◆ NumElts

unsigned VectorSlice::NumElts = 0

Definition at line 1890 of file AMDGPUCodeGenPrepare.cpp.

Referenced by getSlicedVal().

◆ Ty

Type* VectorSlice::Ty = nullptr

Definition at line 1888 of file AMDGPUCodeGenPrepare.cpp.


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