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 RISCVII::VLMUL llvm::RISCVVType::twoTimesVLMUL (RISCVII::VLMUL VLMul)
 Return the RISCVII::VLMUL that is two times VLMul.
 
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 OperandInfo getIntegerExtensionOperandInfo (unsigned Factor, const MachineInstr &MI, const MachineOperand &MO)
 Dest has EEW=SEW and EMUL=LMUL.
 
static bool isMaskOperand (const MachineInstr &MI, const MachineOperand &MO, const MachineRegisterInfo *MRI)
 Check whether MO is a mask operand of MI.
 
static OperandInfo getOperandInfo (const MachineOperand &MO, const MachineRegisterInfo *MRI)
 Return the OperandInfo for MO.
 
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

◆ getIntegerExtensionOperandInfo()

static OperandInfo getIntegerExtensionOperandInfo ( unsigned  Factor,
const MachineInstr MI,
const MachineOperand MO 
)
static

Dest has EEW=SEW and EMUL=LMUL.

Source EEW=SEW/Factor (i.e. F2 => EEW/2). Source has EMUL=(EEW/SEW)*LMUL. LMUL and SEW comes from TSFlags of MI.

Definition at line 185 of file RISCVVLOptimizer.cpp.

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

Referenced by getOperandInfo().

◆ getOperandInfo()

static OperandInfo getOperandInfo ( 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 204 of file RISCVVLOptimizer.cpp.

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

Referenced by getOperandInfo().

◆ 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 627 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 811 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 70 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 844 of file RISCVVLOptimizer.cpp.

References MI, and llvm::RVV.

◆ operator<<()

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

Definition at line 125 of file RISCVVLOptimizer.cpp.

References OS, and OperandInfo::print().