LLVM 22.0.0git
llvm::VPInstruction Class Reference

This is a concrete Recipe that models a single VPlan-level instruction. More...

#include "Transforms/Vectorize/VPlan.h"

Inheritance diagram for llvm::VPInstruction:
[legend]

Public Types

enum  {
  FirstOrderRecurrenceSplice , Not , SLPLoad , SLPStore ,
  ActiveLaneMask , ExplicitVectorLength , CalculateTripCountMinusVF , CanonicalIVIncrementForPart ,
  BranchOnCount , BranchOnCond , Broadcast , BuildStructVector ,
  BuildVector , ComputeAnyOfResult , ComputeFindIVResult , ComputeReductionResult ,
  ExtractLastElement , ExtractPenultimateElement , LogicalAnd , PtrAdd ,
  WidePtrAdd , AnyOf , FirstActiveLane , WideIVStep ,
  ReductionStartVector , StepVector , ExtractLane , ResumeForEpilogue ,
  VScale
}
 VPlan opcodes, extending LLVM IR with idiomatics instructions. More...
Public Types inherited from llvm::VPDef
using VPRecipeTy
 An enumeration for keeping track of the concrete subclass of VPRecipeBase that is actually instantiated.
Public Types inherited from llvm::VPUser
typedef SmallVectorImpl< VPValue * >::iterator operand_iterator
typedef SmallVectorImpl< VPValue * >::const_iterator const_operand_iterator
typedef iterator_range< operand_iteratoroperand_range
typedef iterator_range< const_operand_iteratorconst_operand_range
Public Types inherited from llvm::VPValue
enum  { VPValueSC , VPVRecipeSC }
 An enumeration for keeping track of the concrete subclass of VPValue that are actually instantiated. More...
typedef SmallVectorImpl< VPUser * >::iterator user_iterator
typedef SmallVectorImpl< VPUser * >::const_iterator const_user_iterator
typedef iterator_range< user_iteratoruser_range
typedef iterator_range< const_user_iteratorconst_user_range

Public Member Functions

 VPInstruction (unsigned Opcode, ArrayRef< VPValue * > Operands, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
 VPInstruction (unsigned Opcode, ArrayRef< VPValue * > Operands, const VPIRFlags &Flags, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
VPInstructionclone () override
 Clone the current recipe.
unsigned getOpcode () const
void execute (VPTransformState &State) override
 Generate the instruction.
InstructionCost computeCost (ElementCount VF, VPCostContext &Ctx) const override
 Return the cost of this VPInstruction.
void print (raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
 Print the VPInstruction to O.
LLVM_DUMP_METHOD void dump () const
 Print the VPInstruction to dbgs() (for debugging).
bool hasResult () const
bool opcodeMayReadOrWriteFromMemory () const
 Returns true if the underlying opcode may read from or write to memory.
bool onlyFirstLaneUsed (const VPValue *Op) const override
 Returns true if the recipe only uses the first lane of operand Op.
bool onlyFirstPartUsed (const VPValue *Op) const override
 Returns true if the recipe only uses the first part of operand Op.
bool isVectorToScalar () const
 Returns true if this VPInstruction produces a scalar value from a vector, e.g.
bool isSingleScalar () const
 Returns true if this VPInstruction's operands are single scalars and the result is also a single scalar.
StringRef getName () const
 Returns the symbolic name assigned to the VPInstruction.
Public Member Functions inherited from llvm::VPRecipeWithIRFlags
 VPRecipeWithIRFlags (const unsigned char SC, ArrayRef< VPValue * > Operands, DebugLoc DL=DebugLoc::getUnknown())
 VPRecipeWithIRFlags (const unsigned char SC, ArrayRef< VPValue * > Operands, Instruction &I)
 VPRecipeWithIRFlags (const unsigned char SC, ArrayRef< VPValue * > Operands, const VPIRFlags &Flags, DebugLoc DL=DebugLoc::getUnknown())
std::optional< InstructionCostgetCostForRecipeWithOpcode (unsigned Opcode, ElementCount VF, VPCostContext &Ctx) const
 Compute the cost for this recipe for VF, using Opcode and Ctx.
Public Member Functions inherited from llvm::VPSingleDefRecipe
 VPSingleDefRecipe (const unsigned char SC, ArrayRef< VPValue * > Operands, DebugLoc DL=DebugLoc::getUnknown())
 VPSingleDefRecipe (const unsigned char SC, ArrayRef< VPValue * > Operands, Value *UV, DebugLoc DL=DebugLoc::getUnknown())
InstructiongetUnderlyingInstr ()
 Returns the underlying instruction.
const InstructiongetUnderlyingInstr () const
LLVM_DUMP_METHOD void dump () const
 Print this VPSingleDefRecipe to dbgs() (for debugging).
Public Member Functions inherited from llvm::VPRecipeBase
 VPRecipeBase (const unsigned char SC, ArrayRef< VPValue * > Operands, DebugLoc DL=DebugLoc::getUnknown())
virtual ~VPRecipeBase ()=default
VPBasicBlockgetParent ()
const VPBasicBlockgetParent () const
InstructionCost cost (ElementCount VF, VPCostContext &Ctx)
 Return the cost of this recipe, taking into account if the cost computation should be skipped and the ForceTargetInstructionCost flag.
void insertBefore (VPRecipeBase *InsertPos)
 Insert an unlinked recipe into a basic block immediately before the specified recipe.
void insertBefore (VPBasicBlock &BB, iplist< VPRecipeBase >::iterator IP)
 Insert an unlinked recipe into BB immediately before the insertion point IP;.
void insertAfter (VPRecipeBase *InsertPos)
 Insert an unlinked Recipe into a basic block immediately after the specified Recipe.
void moveAfter (VPRecipeBase *MovePos)
 Unlink this recipe from its current VPBasicBlock and insert it into the VPBasicBlock that MovePos lives in, right after MovePos.
void moveBefore (VPBasicBlock &BB, iplist< VPRecipeBase >::iterator I)
 Unlink this recipe and insert into BB before I.
void removeFromParent ()
 This method unlinks 'this' from the containing basic block, but does not delete it.
iplist< VPRecipeBase >::iterator eraseFromParent ()
 This method unlinks 'this' from the containing basic block and deletes it.
bool mayHaveSideEffects () const
 Returns true if the recipe may have side-effects.
bool isPhi () const
 Returns true for PHI-like recipes.
bool mayReadFromMemory () const
 Returns true if the recipe may read from memory.
bool mayWriteToMemory () const
 Returns true if the recipe may write to memory.
bool mayReadOrWriteMemory () const
 Returns true if the recipe may read from or write to memory.
DebugLoc getDebugLoc () const
 Returns the debug location of the recipe.
bool isScalarCast () const
 Return true if the recipe is a scalar cast.
void setDebugLoc (DebugLoc NewDL)
 Set the recipe's debug location to NewDL.
Public Member Functions inherited from llvm::ilist_node_with_parent< VPRecipeBase, VPBasicBlock >
VPRecipeBasegetPrevNode ()
VPRecipeBasegetNextNode ()
 Get the next node, or nullptr for the list tail.
Public Member Functions inherited from llvm::ilist_node_impl< ilist_detail::compute_node_options< VPRecipeBase, Options... >::type >
self_iterator getIterator ()
reverse_self_iterator getReverseIterator ()
std::enable_if_t< T::is_sentinel_tracking_explicit, boolisSentinel () const
 Check whether this is the sentinel node.
Public Member Functions inherited from llvm::ilist_detail::node_parent_access< ilist_node_impl< ilist_detail::compute_node_options< VPRecipeBase, Options... >::type >, ilist_detail::compute_node_options< VPRecipeBase, Options... >::type::parent_ty >
const ilist_detail::compute_node_options< VPRecipeBase, Options... >::type::parent_ty * getParent () const
void setParent (ilist_detail::compute_node_options< VPRecipeBase, Options... >::type::parent_ty *Parent)
Public Member Functions inherited from llvm::VPDef
 VPDef (const unsigned char SC)
virtual ~VPDef ()
VPValuegetVPSingleValue ()
 Returns the only VPValue defined by the VPDef.
const VPValuegetVPSingleValue () const
VPValuegetVPValue (unsigned I)
 Returns the VPValue with index I defined by the VPDef.
const VPValuegetVPValue (unsigned I) const
ArrayRef< VPValue * > definedValues ()
 Returns an ArrayRef of the values defined by the VPDef.
ArrayRef< VPValue * > definedValues () const
 Returns an ArrayRef of the values defined by the VPDef.
unsigned getNumDefinedValues () const
 Returns the number of values defined by the VPDef.
unsigned getVPDefID () const
void dump () const
 Dump the VPDef to stderr (for debugging).
Public Member Functions inherited from llvm::VPUser
 VPUser ()=delete
 VPUser (const VPUser &)=delete
VPUseroperator= (const VPUser &)=delete
virtual ~VPUser ()
void addOperand (VPValue *Operand)
unsigned getNumOperands () const
VPValuegetOperand (unsigned N) const
void setOperand (unsigned I, VPValue *New)
void swapOperands ()
 Swap operands of the VPUser. It must have exactly 2 operands.
void replaceUsesOfWith (VPValue *From, VPValue *To)
 Replaces all uses of From in the VPUser with To.
operand_iterator op_begin ()
const_operand_iterator op_begin () const
operand_iterator op_end ()
const_operand_iterator op_end () const
operand_range operands ()
const_operand_range operands () const
virtual bool usesScalars (const VPValue *Op) const
 Returns true if the VPUser uses scalars of operand Op.
Public Member Functions inherited from llvm::VPValue
ValuegetUnderlyingValue () const
 Return the underlying Value attached to this VPValue.
 VPValue (const VPValue &)=delete
VPValueoperator= (const VPValue &)=delete
virtual ~VPValue ()
unsigned getVPValueID () const
void printAsOperand (raw_ostream &OS, VPSlotTracker &Tracker) const
void print (raw_ostream &OS, VPSlotTracker &Tracker) const
void dump () const
 Dump the value to stderr (for debugging).
unsigned getNumUsers () const
void addUser (VPUser &User)
void removeUser (VPUser &User)
 Remove a single User from the list of users.
user_iterator user_begin ()
const_user_iterator user_begin () const
user_iterator user_end ()
const_user_iterator user_end () const
user_range users ()
const_user_range users () const
bool hasMoreThanOneUniqueUser () const
 Returns true if the value has more than one unique user.
void replaceAllUsesWith (VPValue *New)
void replaceUsesWithIf (VPValue *New, llvm::function_ref< bool(VPUser &U, unsigned Idx)> ShouldReplace)
 Go through the uses list for this VPValue and make each use point to New if the callback ShouldReplace returns true for the given use specified by a pair of (VPUser, the use index).
VPRecipeBasegetDefiningRecipe ()
 Returns the recipe defining this VPValue or nullptr if it is not defined by a recipe, i.e.
const VPRecipeBasegetDefiningRecipe () const
bool hasDefiningRecipe () const
 Returns true if this VPValue is defined by a recipe.
bool isLiveIn () const
 Returns true if this VPValue is a live-in, i.e. defined outside the VPlan.
ValuegetLiveInIRValue () const
 Returns the underlying IR value, if this VPValue is defined outside the scope of VPlan.
bool isDefinedOutsideLoopRegions () const
 Returns true if the VPValue is defined outside any loop.
void setUnderlyingValue (Value *Val)
Public Member Functions inherited from llvm::VPIRFlags
 VPIRFlags ()
 VPIRFlags (Instruction &I)
 VPIRFlags (CmpInst::Predicate Pred)
 VPIRFlags (WrapFlagsTy WrapFlags)
 VPIRFlags (FastMathFlags FMFs)
 VPIRFlags (DisjointFlagsTy DisjointFlags)
 VPIRFlags (NonNegFlagsTy NonNegFlags)
 VPIRFlags (GEPNoWrapFlags GEPFlags)
void transferFlags (VPIRFlags &Other)
void dropPoisonGeneratingFlags ()
 Drop all poison-generating flags.
void applyFlags (Instruction &I) const
 Apply the IR flags to I.
CmpInst::Predicate getPredicate () const
void setPredicate (CmpInst::Predicate Pred)
GEPNoWrapFlags getGEPNoWrapFlags () const
bool hasPredicate () const
 Returns true if the recipe has a comparison predicate.
bool hasFastMathFlags () const
 Returns true if the recipe has fast-math flags.
LLVM_ABI_FOR_TEST FastMathFlags getFastMathFlags () const
bool hasNonNegFlag () const
 Returns true if the recipe has non-negative flag.
bool isNonNeg () const
bool hasNoUnsignedWrap () const
bool hasNoSignedWrap () const
bool isDisjoint () const
bool flagsValidForOpcode (unsigned Opcode) const
 Returns true if the set flags are valid for Opcode.
void printFlags (raw_ostream &O) const

Friends

class VPlanSlp

Additional Inherited Members

Static Public Member Functions inherited from llvm::VPRecipeWithIRFlags
static bool classof (const VPRecipeBase *R)
static bool classof (const VPUser *U)
static bool classof (const VPValue *V)
static bool classof (const VPSingleDefRecipe *U)
Static Public Member Functions inherited from llvm::VPSingleDefRecipe
static bool classof (const VPRecipeBase *R)
static bool classof (const VPUser *U)
Static Public Member Functions inherited from llvm::VPRecipeBase
static bool classof (const VPDef *D)
 Method to support type inquiry through isa, cast, and dyn_cast.
static bool classof (const VPUser *U)
Protected Types inherited from llvm::ilist_node_impl< ilist_detail::compute_node_options< VPRecipeBase, Options... >::type >
using self_iterator
using const_self_iterator
using reverse_self_iterator
using const_reverse_self_iterator
Protected Member Functions inherited from llvm::ilist_node_with_parent< VPRecipeBase, VPBasicBlock >
 ilist_node_with_parent ()=default
Protected Member Functions inherited from llvm::ilist_node_impl< ilist_detail::compute_node_options< VPRecipeBase, Options... >::type >
 ilist_node_impl ()=default
Protected Member Functions inherited from llvm::VPUser
void printOperands (raw_ostream &O, VPSlotTracker &SlotTracker) const
 Print the operands to O.
 VPUser (ArrayRef< VPValue * > Operands)
Protected Member Functions inherited from llvm::VPValue
 VPValue (const unsigned char SC, Value *UV=nullptr, VPDef *Def=nullptr)
 VPValue (Value *UV=nullptr)
 Create a live-in VPValue.
 VPValue (VPDef *Def, Value *UV=nullptr)
 Create a VPValue for a Def which is a subclass of VPValue.
 VPValue (Value *UV, VPDef *Def)
 Create a VPValue for a Def which defines multiple values.
Protected Member Functions inherited from llvm::VPUnrollPartAccessor< 1 >
VPValuegetUnrollPartOperand (const VPUser &U) const
 Return the VPValue operand containing the unroll part or null if there is no such operand.
unsigned getUnrollPart (const VPUser &U) const
 Return the unroll part.
Protected Attributes inherited from llvm::VPValue
ValueUnderlyingVal
VPDefDef
 Pointer to the VPDef that defines this VPValue.

Detailed Description

This is a concrete Recipe that models a single VPlan-level instruction.

While as any Recipe it may generate a sequence of IR instructions when executed, these instructions would always form a single-def expression as the VPInstruction is also a single def-use vertex.

Definition at line 973 of file VPlan.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

VPlan opcodes, extending LLVM IR with idiomatics instructions.

Enumerator
FirstOrderRecurrenceSplice 
Not 
SLPLoad 
SLPStore 
ActiveLaneMask 
ExplicitVectorLength 
CalculateTripCountMinusVF 
CanonicalIVIncrementForPart 
BranchOnCount 
BranchOnCond 
Broadcast 
BuildStructVector 

Given operands of (the same) struct type, creates a struct of fixed- width vectors each containing a struct field of all operands.

The number of operands matches the element count of every vector.

BuildVector 

Creates a fixed-width vector containing all operands.

The number of operands matches the vector element count.

ComputeAnyOfResult 

Compute the final result of a AnyOf reduction with select(cmp(),x,y), where one of (x,y) is loop invariant, and both x and y are integer type.

ComputeFindIVResult 
ComputeReductionResult 
ExtractLastElement 
ExtractPenultimateElement 
LogicalAnd 
PtrAdd 
WidePtrAdd 
AnyOf 
FirstActiveLane 
WideIVStep 

Scale the first operand (vector step) by the second operand (scalar-step).

Casts both operands to the result type if needed.

ReductionStartVector 

Start vector for reductions with 3 operands: the original start value, the identity value for the reduction and an integer indicating the scaling factor.

StepVector 
ExtractLane 

Extracts a single lane (first operand) from a set of vector operands.

The lane specifies an index into a vector formed by combining all vector operands (all operands after the first one).

ResumeForEpilogue 

Explicit user for the resume phi of the canonical induction in the main VPlan, used by the epilogue vector loop.

VScale 

Returns the value for vscale.

Definition at line 980 of file VPlan.h.

Constructor & Destructor Documentation

◆ VPInstruction() [1/2]

◆ VPInstruction() [2/2]

Member Function Documentation

◆ clone()

VPInstruction * llvm::VPInstruction::clone ( )
inlineoverridevirtual

◆ computeCost()

◆ dump()

void VPInstruction::dump ( ) const

Print the VPInstruction to dbgs() (for debugging).

Definition at line 1288 of file VPlanRecipes.cpp.

References llvm::dbgs(), llvm::VPRecipeBase::getParent(), and print().

◆ execute()

void VPInstruction::execute ( VPTransformState & State)
overridevirtual

◆ getName()

StringRef llvm::VPInstruction::getName ( ) const
inline

Returns the symbolic name assigned to the VPInstruction.

Definition at line 1176 of file VPlan.h.

Referenced by llvm::VPInstructionWithType::clone(), and llvm::VPPhi::execute().

◆ getOpcode()

◆ hasResult()

bool llvm::VPInstruction::hasResult ( ) const
inline

Definition at line 1136 of file VPlan.h.

References BranchOnCond, BranchOnCount, and getOpcode().

Referenced by execute(), and print().

◆ isSingleScalar()

bool VPInstruction::isSingleScalar ( ) const

Returns true if this VPInstruction's operands are single scalars and the result is also a single scalar.

Definition at line 1145 of file VPlanRecipes.cpp.

References ExplicitVectorLength, getOpcode(), llvm::VPRecipeBase::isScalarCast(), ResumeForEpilogue, and VScale.

Referenced by execute(), print(), llvm::VPInstructionWithType::print(), and llvm::VPPhi::print().

◆ isVectorToScalar()

bool VPInstruction::isVectorToScalar ( ) const

Returns true if this VPInstruction produces a scalar value from a vector, e.g.

by performing a reduction or extracting a lane.

Definition at line 1133 of file VPlanRecipes.cpp.

References AnyOf, ComputeAnyOfResult, ComputeFindIVResult, ComputeReductionResult, ExtractLane, ExtractLastElement, ExtractPenultimateElement, FirstActiveLane, and getOpcode().

Referenced by execute(), and simplifyRecipe().

◆ onlyFirstLaneUsed()

◆ onlyFirstPartUsed()

bool VPInstruction::onlyFirstPartUsed ( const VPValue * Op) const
overridevirtual

◆ opcodeMayReadOrWriteFromMemory()

◆ print()

◆ VPlanSlp

friend class VPlanSlp
friend

Definition at line 976 of file VPlan.h.

References VPlanSlp.

Referenced by VPlanSlp.


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