Skip to content

Commit

Permalink
[RISCV] Refactor isAllOnesMask. NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
lukel97 committed Nov 15, 2023
1 parent aa8af04 commit 1b781ee
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions llvm/lib/Target/RISCV/RISCVFoldMasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class RISCVFoldMasks : public MachineFunctionPass {
private:
bool convertVMergeToVMv(MachineInstr &MI, MachineInstr *MaskDef);

bool isAllOnesMask(MachineInstr *MaskCopy);
bool isAllOnesMask(MachineInstr *MaskDef);
};

} // namespace
Expand All @@ -59,22 +59,21 @@ char RISCVFoldMasks::ID = 0;

INITIALIZE_PASS(RISCVFoldMasks, DEBUG_TYPE, "RISC-V Fold Masks", false, false)

bool RISCVFoldMasks::isAllOnesMask(MachineInstr *MaskCopy) {
if (!MaskCopy)
bool RISCVFoldMasks::isAllOnesMask(MachineInstr *MaskDef) {
if (!MaskDef)
return false;
assert(MaskCopy->isCopy() && MaskCopy->getOperand(0).getReg() == RISCV::V0);
Register SrcReg =
TRI->lookThruCopyLike(MaskCopy->getOperand(1).getReg(), MRI);
assert(MaskDef->isCopy() && MaskDef->getOperand(0).getReg() == RISCV::V0);
Register SrcReg = TRI->lookThruCopyLike(MaskDef->getOperand(1).getReg(), MRI);
if (!SrcReg.isVirtual())
return false;
MachineInstr *SrcDef = MRI->getVRegDef(SrcReg);
if (!SrcDef)
MaskDef = MRI->getVRegDef(SrcReg);
if (!MaskDef)
return false;

// TODO: Check that the VMSET is the expected bitwidth? The pseudo has
// undefined behaviour if it's the wrong bitwidth, so we could choose to
// assume that it's all-ones? Same applies to its VL.
switch (SrcDef->getOpcode()) {
switch (MaskDef->getOpcode()) {
case RISCV::PseudoVMSET_M_B1:
case RISCV::PseudoVMSET_M_B2:
case RISCV::PseudoVMSET_M_B4:
Expand Down

0 comments on commit 1b781ee

Please sign in to comment.