Skip to content

Commit

Permalink
[RISCV] Add helper to copy the AVL of another VSETVLIInfo. NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
lukel97 committed Nov 30, 2023
1 parent 586986a commit c0b9269
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,18 @@ class VSETVLIInfo {
return AVLImm;
}

void setAVL(VSETVLIInfo Info) {
assert(Info.isValid());
if (Info.isUnknown())
setUnknown();
else if (Info.hasAVLReg())
setAVLReg(Info.getAVLReg());
else {
assert(Info.hasAVLImm());
setAVLImm(Info.getAVLImm());
}
}

unsigned getSEW() const { return SEW; }
RISCVII::VLMUL getVLMUL() const { return VLMul; }

Expand Down Expand Up @@ -1054,10 +1066,7 @@ void RISCVInsertVSETVLI::transferBefore(VSETVLIInfo &Info,
// TODO: We can probably relax this for immediates.
if (Demanded.VLZeroness && !Demanded.VLAny && PrevInfo.isValid() &&
PrevInfo.hasEquallyZeroAVL(Info, *MRI) && Info.hasSameVLMAX(PrevInfo)) {
if (PrevInfo.hasAVLImm())
Info.setAVLImm(PrevInfo.getAVLImm());
else
Info.setAVLReg(PrevInfo.getAVLReg());
Info.setAVL(PrevInfo);
return;
}

Expand All @@ -1074,10 +1083,7 @@ void RISCVInsertVSETVLI::transferBefore(VSETVLIInfo &Info,
VSETVLIInfo DefInfo = getInfoForVSETVLI(*DefMI);
if (DefInfo.hasSameVLMAX(Info) &&
(DefInfo.hasAVLImm() || DefInfo.getAVLReg() == RISCV::X0)) {
if (DefInfo.hasAVLImm())
Info.setAVLImm(DefInfo.getAVLImm());
else
Info.setAVLReg(DefInfo.getAVLReg());
Info.setAVL(DefInfo);
return;
}
}
Expand Down

0 comments on commit c0b9269

Please sign in to comment.