LLVM 20.0.0git
Classes | Namespaces | Macros | Functions
RISCVVLOptimizer.cpp File Reference
#include "RISCV.h"
#include "RISCVSubtarget.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/InitializePasses.h"

Go to the source code of this file.

Classes

struct  OperandInfo
 Represents the EMUL and EEW of a MachineOperand. More...
 

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
 
namespace  llvm::RISCVVType
 

Macros

#define DEBUG_TYPE   "riscv-vl-optimizer"
 
#define PASS_NAME   "RISC-V VL Optimizer"
 

Functions

static bool isVectorRegClass (Register R, const MachineRegisterInfo *MRI)
 Return true if R is a physical or virtual vector register, false otherwise.
 
static LLVM_ATTRIBUTE_UNUSED raw_ostreamoperator<< (raw_ostream &OS, const OperandInfo &OI)
 
static LLVM_ATTRIBUTE_UNUSED raw_ostreamoperator<< (raw_ostream &OS, const std::optional< OperandInfo > &OI)
 
static std::pair< unsigned, boolllvm::RISCVVType::getEMULEqualsEEWDivSEWTimesLMUL (unsigned Log2EEW, const MachineInstr &MI)
 Return EMUL = (EEW / SEW) * LMUL where EEW comes from Log2EEW and LMUL and SEW are from the TSFlags of MI.
 
static unsigned getIntegerExtensionOperandEEW (unsigned Factor, const MachineInstr &MI, const MachineOperand &MO)
 Dest has EEW=SEW.
 
static bool isMaskOperand (const MachineInstr &MI, const MachineOperand &MO, const MachineRegisterInfo *MRI)
 Check whether MO is a mask operand of MI.
 
static std::optional< unsignedgetOperandLog2EEW (const MachineOperand &MO, const MachineRegisterInfo *MRI)
 
static std::optional< OperandInfogetOperandInfo (const MachineOperand &MO, const MachineRegisterInfo *MRI)
 
static bool isSupportedInstr (const MachineInstr &MI)
 Return true if this optimization should consider MI for VL reduction.
 
static bool isVectorOpUsedAsScalarOp (MachineOperand &MO)
 Return true if MO is a vector operand but is used as a scalar operand.
 
static bool mayReadPastVL (const MachineInstr &MI)
 Return true if MI may read elements past VL.
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "riscv-vl-optimizer"

Definition at line 28 of file RISCVVLOptimizer.cpp.

◆ PASS_NAME

#define PASS_NAME   "RISC-V VL Optimizer"

Definition at line 29 of file RISCVVLOptimizer.cpp.

Function Documentation

◆ getIntegerExtensionOperandEEW()

static unsigned getIntegerExtensionOperandEEW ( unsigned  Factor,
const MachineInstr MI,
const MachineOperand MO 
)
static

Dest has EEW=SEW.

Source EEW=SEW/Factor (i.e. F2 => EEW/2). SEW comes from TSFlags of MI.

Definition at line 169 of file RISCVVLOptimizer.cpp.

References llvm::MachineOperand::getOperandNo(), llvm::RISCVII::getSEWOpNum(), llvm::Log2_32(), and MI.

Referenced by getOperandLog2EEW().

◆ getOperandInfo()

static std::optional< OperandInfo > getOperandInfo ( const MachineOperand MO,
const MachineRegisterInfo MRI 
)
static

◆ getOperandLog2EEW()

static std::optional< unsigned > getOperandLog2EEW ( const MachineOperand MO,
const MachineRegisterInfo MRI 
)
static

◆ isMaskOperand()

static bool isMaskOperand ( const MachineInstr MI,
const MachineOperand MO,
const MachineRegisterInfo MRI 
)
static

Check whether MO is a mask operand of MI.

Definition at line 186 of file RISCVVLOptimizer.cpp.

References llvm::MachineOperand::getOperandNo(), llvm::MachineOperand::getReg(), llvm::MachineOperand::isReg(), isVectorRegClass(), MI, and MRI.

Referenced by getOperandLog2EEW().

◆ isSupportedInstr()

static bool isSupportedInstr ( const MachineInstr MI)
static

Return true if this optimization should consider MI for VL reduction.

This white-list approach simplifies this optimization for instructions that may have more complex semantics with relation to how it uses VL.

Definition at line 778 of file RISCVVLOptimizer.cpp.

References MI, and llvm::RVV.

◆ isVectorOpUsedAsScalarOp()

static bool isVectorOpUsedAsScalarOp ( MachineOperand MO)
static

Return true if MO is a vector operand but is used as a scalar operand.

Definition at line 1064 of file RISCVVLOptimizer.cpp.

References llvm::MachineOperand::getOperandNo(), llvm::MachineOperand::getParent(), MI, and llvm::RVV.

◆ isVectorRegClass()

static bool isVectorRegClass ( Register  R,
const MachineRegisterInfo MRI 
)
static

Return true if R is a physical or virtual vector register, false otherwise.

Definition at line 73 of file RISCVVLOptimizer.cpp.

References llvm::RISCVRI::isVRegClass(), MRI, and llvm::TargetRegisterClass::TSFlags.

Referenced by isMaskOperand().

◆ mayReadPastVL()

static bool mayReadPastVL ( const MachineInstr MI)
static

Return true if MI may read elements past VL.

Definition at line 1100 of file RISCVVLOptimizer.cpp.

References MI, and llvm::RVV.

◆ operator<<() [1/2]

static LLVM_ATTRIBUTE_UNUSED raw_ostream & operator<< ( raw_ostream OS,
const OperandInfo OI 
)
static

Definition at line 121 of file RISCVVLOptimizer.cpp.

References OS, and OperandInfo::print().

◆ operator<<() [2/2]

static LLVM_ATTRIBUTE_UNUSED raw_ostream & operator<< ( raw_ostream OS,
const std::optional< OperandInfo > &  OI 
)
static

Definition at line 127 of file RISCVVLOptimizer.cpp.

References OS.