LLVM 24.0.0git
llvm::VPBuilder Class Reference

VPlan-based builder utility analogous to IRBuilder. More...

#include "Transforms/Vectorize/LoopVectorizationPlanner.h"

Classes

class  InsertPointGuard
 RAII object that stores the current insertion point and restores it when the object is destroyed. More...

Public Member Functions

VPlangetPlan () const
 VPBuilder ()=default
 VPBuilder (const VPInsertPoint &IP)
 VPBuilder (VPBasicBlock *TheBB, VPBasicBlock::iterator IP)
VPRecipeBasegetRecipeAtInsertPoint () const
 Get the recipe at the current insert point or nullptr if the insert point is the end of the block.
void restoreIP (VPInsertPoint IP)
 Sets the current insert point to a previously-saved location.
void setInsertPoint (const VPInsertPoint &IP)
 Set the current insert point.
void setInsertPoint (VPBasicBlock *TheBB, VPBasicBlock::iterator IP)
template<typename T>
Tinsert (T *R)
 Insert R at the current insertion point. Returns R unchanged.
VPInstructioncreateNaryOp (unsigned Opcode, ArrayRef< VPValue * > Operands, Instruction *Inst=nullptr, const VPIRFlags &Flags={}, const VPIRMetadata &MD={}, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="", Type *ResultTy=nullptr)
 Create an N-ary operation with Opcode, Operands and set Inst as its underlying Instruction.
VPInstructioncreateNaryOp (unsigned Opcode, ArrayRef< VPValue * > Operands, DebugLoc DL, const Twine &Name="")
VPInstructioncreateNaryOp (unsigned Opcode, ArrayRef< VPValue * > Operands, const VPIRFlags &Flags, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
VPInstructioncreateNaryOp (unsigned Opcode, ArrayRef< VPValue * > Operands, Type *ResultTy, const VPIRFlags &Flags={}, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
VPInstructioncreateFirstActiveLane (ArrayRef< VPValue * > Masks, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
VPInstructioncreateLastActiveLane (ArrayRef< VPValue * > Masks, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
VPInstructioncreateOverflowingOp (unsigned Opcode, ArrayRef< VPValue * > Operands, VPRecipeWithIRFlags::WrapFlagsTy WrapFlags={false, false}, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
VPInstructioncreateNot (VPValue *Operand, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
VPInstructioncreateAnd (VPValue *LHS, VPValue *RHS, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
VPInstructioncreateOr (VPValue *LHS, VPValue *RHS, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
VPInstructioncreateAdd (VPValue *LHS, VPValue *RHS, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="", VPRecipeWithIRFlags::WrapFlagsTy WrapFlags={false, false})
VPInstructioncreateSub (VPValue *LHS, VPValue *RHS, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="", VPRecipeWithIRFlags::WrapFlagsTy WrapFlags={false, false})
VPInstructioncreateLogicalAnd (VPValue *LHS, VPValue *RHS, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
VPInstructioncreateLogicalOr (VPValue *LHS, VPValue *RHS, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
VPInstructioncreateSelect (VPValue *Cond, VPValue *TrueVal, VPValue *FalseVal, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="", std::optional< VPIRFlags > Flags=std::nullopt)
 Create a select of TrueVal and FalseVal based on Cond, using the default flags for the result type, unless Flags is set.
VPInstructioncreateICmp (CmpInst::Predicate Pred, VPValue *A, VPValue *B, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
 Create a new ICmp VPInstruction with predicate Pred and operands A and B.
VPInstructioncreateFCmp (CmpInst::Predicate Pred, VPValue *A, VPValue *B, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
 Create a new FCmp VPInstruction with predicate Pred and operands A and B.
VPInstructioncreateAnyOfReduction (VPValue *ChainOp, VPValue *TrueVal, VPValue *FalseVal, DebugLoc DL=DebugLoc::getUnknown())
 Create an AnyOf reduction pattern: or-reduce ChainOp, freeze the result, then select between TrueVal and FalseVal.
VPInstructioncreatePtrAdd (VPValue *Ptr, VPValue *Offset, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
VPInstructioncreateNoWrapPtrAdd (VPValue *Ptr, VPValue *Offset, GEPNoWrapFlags GEPFlags, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
VPInstructioncreateWidePtrAdd (VPValue *Ptr, VPValue *Offset, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
VPPhicreateScalarPhi (ArrayRef< VPValue * > IncomingValues, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="", std::optional< VPIRFlags > Flags=std::nullopt, Type *ResultTy=nullptr)
 Create a phi with IncomingValues, using the default flags for the result type, unless Flags is set.
VPWidenPHIRecipecreateWidenPhi (ArrayRef< VPValue * > IncomingValues, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
VPValuecreateElementCount (Type *Ty, ElementCount EC)
VPDerivedIVRecipecreateDerivedIV (InductionDescriptor::InductionKind Kind, FPMathOperator *FPBinOp, VPValue *Start, VPValue *Current, VPValue *Step, const VPIRFlags::WrapFlagsTy &Flags={})
 Convert Current to Start + Current * Step.
VPInstructioncreateScalarCast (Instruction::CastOps Opcode, VPValue *Op, Type *ResultTy, DebugLoc DL, std::optional< VPIRFlags > Flags=std::nullopt, const VPIRMetadata &Metadata={})
VPInstructioncreateScalarIntrinsic (Intrinsic::ID IntrinsicID, ArrayRef< VPValue * > Operands, Type *ResultTy, DebugLoc DL)
 Create a scalar call to the intrinsic IntrinsicID with Operands, and result type ResultTy.
VPInstructioncreateVScale (Type *ResultTy, DebugLoc DL=DebugLoc::getUnknown())
 Create a scalar llvm.vscale call.
VPValuecreateScalarZExtOrTrunc (VPValue *Op, Type *ResultTy, DebugLoc DL)
VPValuecreateScalarSExtOrTrunc (VPValue *Op, Type *ResultTy, DebugLoc DL)
VPInstructioncreateFreeze (VPValue *Op, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
VPWidenCastRecipecreateWidenCast (Instruction::CastOps Opcode, VPValue *Op, Type *ResultTy)
VPScalarIVStepsRecipecreateScalarIVSteps (Instruction::BinaryOps InductionOpcode, FPMathOperator *FPBinOp, VPValue *IV, VPValue *Step, VPValue *VF, DebugLoc DL)
VPExpandSCEVRecipecreateExpandSCEV (const SCEV *Expr)
VPVectorPointerRecipecreateVectorPointer (VPValue *Ptr, Type *SourceElementTy, VPValue *Stride, GEPNoWrapFlags GEPFlags, DebugLoc DL)
VPSingleDefRecipecreateConsecutiveVectorPointer (VPValue *Ptr, Type *SourceElementTy, bool Reverse, DebugLoc DL)
 Create a vector pointer recipe for a consecutive memory access to Ptr with element type SourceElementTy.
VPWidenMemIntrinsicRecipecreateWidenMemIntrinsic (Intrinsic::ID VectorIntrinsicID, ArrayRef< VPValue * > CallArguments, Type *Ty, Align Alignment, const VPIRMetadata &MD, DebugLoc DL)
VPWidenLoadRecipecreateWidenLoad (LoadInst &Load, VPValue *Addr, VPValue *Mask, bool Consecutive, const VPIRMetadata &Metadata, DebugLoc DL)
 Create a recipe widening Load, loading from Addr with Mask (may be null).
VPWidenStoreRecipecreateWidenStore (StoreInst &Store, VPValue *Addr, VPValue *StoredVal, VPValue *Mask, bool Consecutive, const VPIRMetadata &Metadata, DebugLoc DL)
 Create a recipe widening Store, storing StoredVal to Addr with Mask (may be null).

Static Public Member Functions

static VPBuilder getToInsertAfter (VPRecipeBase *R)
 Create a VPBuilder to insert after R.
static VPSingleDefRecipecreateSingleScalarOp (unsigned Opcode, ArrayRef< VPValue * > Operands, VPValue *Mask, const VPIRFlags &Flags, const VPIRMetadata &Metadata, DebugLoc DL, Instruction *UV)
 Create a single-scalar recipe with Opcode and Operands without inserting it.

Detailed Description

VPlan-based builder utility analogous to IRBuilder.

Definition at line 101 of file LoopVectorizationPlanner.h.

Constructor & Destructor Documentation

◆ VPBuilder() [1/3]

llvm::VPBuilder::VPBuilder ( )
default

◆ VPBuilder() [2/3]

llvm::VPBuilder::VPBuilder ( const VPInsertPoint & IP)
inline

Definition at line 158 of file LoopVectorizationPlanner.h.

◆ VPBuilder() [3/3]

llvm::VPBuilder::VPBuilder ( VPBasicBlock * TheBB,
VPBasicBlock::iterator IP )
inline

Definition at line 159 of file LoopVectorizationPlanner.h.

Member Function Documentation

◆ createAdd()

VPInstruction * llvm::VPBuilder::createAdd ( VPValue * LHS,
VPValue * RHS,
DebugLoc DL = DebugLoc::getUnknown(),
const Twine & Name = "",
VPRecipeWithIRFlags::WrapFlagsTy WrapFlags = {false, false} )
inline

◆ createAnd()

VPInstruction * llvm::VPBuilder::createAnd ( VPValue * LHS,
VPValue * RHS,
DebugLoc DL = DebugLoc::getUnknown(),
const Twine & Name = "" )
inline

◆ createAnyOfReduction()

VPInstruction * VPBuilder::createAnyOfReduction ( VPValue * ChainOp,
VPValue * TrueVal,
VPValue * FalseVal,
DebugLoc DL = DebugLoc::getUnknown() )

Create an AnyOf reduction pattern: or-reduce ChainOp, freeze the result, then select between TrueVal and FalseVal.

Definition at line 1620 of file VPlan.cpp.

References assert(), llvm::VPInstruction::ComputeReductionResult, createNaryOp(), createSelect(), DL, llvm::VPValue::getScalarType(), llvm::Type::isIntegerTy(), and llvm::Or.

Referenced by llvm::VPlanTransforms::optimizeFindIVReductions().

◆ createConsecutiveVectorPointer()

VPSingleDefRecipe * VPBuilder::createConsecutiveVectorPointer ( VPValue * Ptr,
Type * SourceElementTy,
bool Reverse,
DebugLoc DL )

◆ createDerivedIV()

VPDerivedIVRecipe * llvm::VPBuilder::createDerivedIV ( InductionDescriptor::InductionKind Kind,
FPMathOperator * FPBinOp,
VPValue * Start,
VPValue * Current,
VPValue * Step,
const VPIRFlags::WrapFlagsTy & Flags = {} )
inline

Convert Current to Start + Current * Step.

Definition at line 410 of file LoopVectorizationPlanner.h.

Referenced by tryToComputeEndValueForInduction().

◆ createElementCount()

VPValue * llvm::VPBuilder::createElementCount ( Type * Ty,
ElementCount EC )
inline

◆ createExpandSCEV()

VPExpandSCEVRecipe * llvm::VPBuilder::createExpandSCEV ( const SCEV * Expr)
inline

Definition at line 508 of file LoopVectorizationPlanner.h.

◆ createFCmp()

VPInstruction * llvm::VPBuilder::createFCmp ( CmpInst::Predicate Pred,
VPValue * A,
VPValue * B,
DebugLoc DL = DebugLoc::getUnknown(),
const Twine & Name = "" )
inline

Create a new FCmp VPInstruction with predicate Pred and operands A and B.

Definition at line 331 of file LoopVectorizationPlanner.h.

References A(), assert(), B(), DL, llvm::CmpInst::FIRST_FCMP_PREDICATE, llvm::DebugLoc::getUnknown(), and llvm::CmpInst::LAST_FCMP_PREDICATE.

Referenced by llvm::VPlanTransforms::handleMaxMinNumReductions().

◆ createFirstActiveLane()

◆ createFreeze()

◆ createICmp()

◆ createLastActiveLane()

◆ createLogicalAnd()

VPInstruction * llvm::VPBuilder::createLogicalAnd ( VPValue * LHS,
VPValue * RHS,
DebugLoc DL = DebugLoc::getUnknown(),
const Twine & Name = "" )
inline

◆ createLogicalOr()

VPInstruction * llvm::VPBuilder::createLogicalOr ( VPValue * LHS,
VPValue * RHS,
DebugLoc DL = DebugLoc::getUnknown(),
const Twine & Name = "" )
inline

◆ createNaryOp() [1/4]

VPInstruction * llvm::VPBuilder::createNaryOp ( unsigned Opcode,
ArrayRef< VPValue * > Operands,
const VPIRFlags & Flags,
DebugLoc DL = DebugLoc::getUnknown(),
const Twine & Name = "" )
inline

Definition at line 208 of file LoopVectorizationPlanner.h.

References DL, llvm::DebugLoc::getUnknown(), and Operands.

◆ createNaryOp() [2/4]

VPInstruction * llvm::VPBuilder::createNaryOp ( unsigned Opcode,
ArrayRef< VPValue * > Operands,
DebugLoc DL,
const Twine & Name = "" )
inline

Definition at line 204 of file LoopVectorizationPlanner.h.

References DL, and Operands.

◆ createNaryOp() [3/4]

◆ createNaryOp() [4/4]

VPInstruction * llvm::VPBuilder::createNaryOp ( unsigned Opcode,
ArrayRef< VPValue * > Operands,
Type * ResultTy,
const VPIRFlags & Flags = {},
DebugLoc DL = DebugLoc::getUnknown(),
const Twine & Name = "" )
inline

Definition at line 216 of file LoopVectorizationPlanner.h.

References Operands.

◆ createNot()

◆ createNoWrapPtrAdd()

VPInstruction * llvm::VPBuilder::createNoWrapPtrAdd ( VPValue * Ptr,
VPValue * Offset,
GEPNoWrapFlags GEPFlags,
DebugLoc DL = DebugLoc::getUnknown(),
const Twine & Name = "" )
inline

◆ createOr()

VPInstruction * llvm::VPBuilder::createOr ( VPValue * LHS,
VPValue * RHS,
DebugLoc DL = DebugLoc::getUnknown(),
const Twine & Name = "" )
inline

◆ createOverflowingOp()

VPInstruction * llvm::VPBuilder::createOverflowingOp ( unsigned Opcode,
ArrayRef< VPValue * > Operands,
VPRecipeWithIRFlags::WrapFlagsTy WrapFlags = {false, false},
DebugLoc DL = DebugLoc::getUnknown(),
const Twine & Name = "" )
inline

◆ createPtrAdd()

VPInstruction * llvm::VPBuilder::createPtrAdd ( VPValue * Ptr,
VPValue * Offset,
DebugLoc DL = DebugLoc::getUnknown(),
const Twine & Name = "" )
inline

◆ createScalarCast()

VPInstruction * llvm::VPBuilder::createScalarCast ( Instruction::CastOps Opcode,
VPValue * Op,
Type * ResultTy,
DebugLoc DL,
std::optional< VPIRFlags > Flags = std::nullopt,
const VPIRMetadata & Metadata = {} )
inline

◆ createScalarIntrinsic()

VPInstruction * llvm::VPBuilder::createScalarIntrinsic ( Intrinsic::ID IntrinsicID,
ArrayRef< VPValue * > Operands,
Type * ResultTy,
DebugLoc DL )
inline

Create a scalar call to the intrinsic IntrinsicID with Operands, and result type ResultTy.

Definition at line 429 of file LoopVectorizationPlanner.h.

References AbstractManglingParser< Derived, Alloc >::Ops, DL, llvm::VPlan::getConstantInt(), getPlan(), llvm::VPInstruction::Intrinsic, and Operands.

Referenced by createVScale().

◆ createScalarIVSteps()

VPScalarIVStepsRecipe * llvm::VPBuilder::createScalarIVSteps ( Instruction::BinaryOps InductionOpcode,
FPMathOperator * FPBinOp,
VPValue * IV,
VPValue * Step,
VPValue * VF,
DebugLoc DL )
inline

Definition at line 500 of file LoopVectorizationPlanner.h.

References DL, llvm::FPMathOperator::getFastMathFlags(), and IV.

◆ createScalarPhi()

VPPhi * llvm::VPBuilder::createScalarPhi ( ArrayRef< VPValue * > IncomingValues,
DebugLoc DL = DebugLoc::getUnknown(),
const Twine & Name = "",
std::optional< VPIRFlags > Flags = std::nullopt,
Type * ResultTy = nullptr )
inline

Create a phi with IncomingValues, using the default flags for the result type, unless Flags is set.

Definition at line 371 of file LoopVectorizationPlanner.h.

References DL, llvm::VPIRFlags::getDefaultFlags(), and llvm::DebugLoc::getUnknown().

Referenced by addInitialSkeleton(), llvm::VPlanTransforms::convertToVariableLengthStep(), llvm::VPRegionBlock::dissolveToCFGLoop(), preparePlanForMainVectorLoop(), and llvm::vputils::reconstructSSA().

◆ createScalarSExtOrTrunc()

VPValue * llvm::VPBuilder::createScalarSExtOrTrunc ( VPValue * Op,
Type * ResultTy,
DebugLoc DL )
inline

◆ createScalarZExtOrTrunc()

VPValue * llvm::VPBuilder::createScalarZExtOrTrunc ( VPValue * Op,
Type * ResultTy,
DebugLoc DL )
inline

◆ createSelect()

VPInstruction * llvm::VPBuilder::createSelect ( VPValue * Cond,
VPValue * TrueVal,
VPValue * FalseVal,
DebugLoc DL = DebugLoc::getUnknown(),
const Twine & Name = "",
std::optional< VPIRFlags > Flags = std::nullopt )
inline

Create a select of TrueVal and FalseVal based on Cond, using the default flags for the result type, unless Flags is set.

Definition at line 306 of file LoopVectorizationPlanner.h.

References Cond, DL, llvm::VPIRFlags::getDefaultFlags(), and llvm::DebugLoc::getUnknown().

Referenced by createAnyOfReduction(), llvm::VPlanTransforms::handleMaxMinNumReductions(), and llvm::VPlanTransforms::optimizeFindIVReductions().

◆ createSingleScalarOp()

◆ createSub()

VPInstruction * llvm::VPBuilder::createSub ( VPValue * LHS,
VPValue * RHS,
DebugLoc DL = DebugLoc::getUnknown(),
const Twine & Name = "",
VPRecipeWithIRFlags::WrapFlagsTy WrapFlags = {false, false} )
inline

Definition at line 285 of file LoopVectorizationPlanner.h.

References DL, llvm::DebugLoc::getUnknown(), LHS, and RHS.

◆ createVectorPointer()

VPVectorPointerRecipe * llvm::VPBuilder::createVectorPointer ( VPValue * Ptr,
Type * SourceElementTy,
VPValue * Stride,
GEPNoWrapFlags GEPFlags,
DebugLoc DL )
inline

Definition at line 513 of file LoopVectorizationPlanner.h.

References DL.

Referenced by createConsecutiveVectorPointer().

◆ createVScale()

VPInstruction * llvm::VPBuilder::createVScale ( Type * ResultTy,
DebugLoc DL = DebugLoc::getUnknown() )
inline

Create a scalar llvm.vscale call.

Definition at line 440 of file LoopVectorizationPlanner.h.

References createScalarIntrinsic(), DL, and llvm::DebugLoc::getUnknown().

Referenced by createElementCount().

◆ createWidenCast()

VPWidenCastRecipe * llvm::VPBuilder::createWidenCast ( Instruction::CastOps Opcode,
VPValue * Op,
Type * ResultTy )
inline

◆ createWidenLoad()

VPWidenLoadRecipe * llvm::VPBuilder::createWidenLoad ( LoadInst & Load,
VPValue * Addr,
VPValue * Mask,
bool Consecutive,
const VPIRMetadata & Metadata,
DebugLoc DL )
inline

Create a recipe widening Load, loading from Addr with Mask (may be null).

Definition at line 534 of file LoopVectorizationPlanner.h.

References DL, and llvm::Load.

Referenced by narrowInterleaveGroupOp().

◆ createWidenMemIntrinsic()

VPWidenMemIntrinsicRecipe * llvm::VPBuilder::createWidenMemIntrinsic ( Intrinsic::ID VectorIntrinsicID,
ArrayRef< VPValue * > CallArguments,
Type * Ty,
Align Alignment,
const VPIRMetadata & MD,
DebugLoc DL )
inline

Definition at line 525 of file LoopVectorizationPlanner.h.

References DL.

◆ createWidenPhi()

VPWidenPHIRecipe * llvm::VPBuilder::createWidenPhi ( ArrayRef< VPValue * > IncomingValues,
DebugLoc DL = DebugLoc::getUnknown(),
const Twine & Name = "" )
inline

Definition at line 383 of file LoopVectorizationPlanner.h.

References DL, and llvm::DebugLoc::getUnknown().

Referenced by expandVPWidenIntOrFpInduction().

◆ createWidenStore()

VPWidenStoreRecipe * llvm::VPBuilder::createWidenStore ( StoreInst & Store,
VPValue * Addr,
VPValue * StoredVal,
VPValue * Mask,
bool Consecutive,
const VPIRMetadata & Metadata,
DebugLoc DL )
inline

Create a recipe widening Store, storing StoredVal to Addr with Mask (may be null).

Definition at line 544 of file LoopVectorizationPlanner.h.

References DL, and llvm::Store.

◆ createWidePtrAdd()

VPInstruction * llvm::VPBuilder::createWidePtrAdd ( VPValue * Ptr,
VPValue * Offset,
DebugLoc DL = DebugLoc::getUnknown(),
const Twine & Name = "" )
inline

◆ getPlan()

VPlan & llvm::VPBuilder::getPlan ( ) const
inline

◆ getRecipeAtInsertPoint()

VPRecipeBase * llvm::VPBuilder::getRecipeAtInsertPoint ( ) const
inline

Get the recipe at the current insert point or nullptr if the insert point is the end of the block.

Definition at line 164 of file LoopVectorizationPlanner.h.

Referenced by llvm::VPlanTransforms::handleMaxMinNumReductions().

◆ getToInsertAfter()

◆ insert()

template<typename T>
T * llvm::VPBuilder::insert ( T * R)
inline

Insert R at the current insertion point. Returns R unchanged.

Definition at line 185 of file LoopVectorizationPlanner.h.

References T.

Referenced by llvm::VPRecipeBuilder::replaceWithFinalIfReductionStore().

◆ restoreIP()

void llvm::VPBuilder::restoreIP ( VPInsertPoint IP)
inline

Sets the current insert point to a previously-saved location.

Definition at line 172 of file LoopVectorizationPlanner.h.

◆ setInsertPoint() [1/2]

void llvm::VPBuilder::setInsertPoint ( const VPInsertPoint & IP)
inline

◆ setInsertPoint() [2/2]

void llvm::VPBuilder::setInsertPoint ( VPBasicBlock * TheBB,
VPBasicBlock::iterator IP )
inline

Definition at line 179 of file LoopVectorizationPlanner.h.

References assert().


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