-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RISCV] Ensure the valid vtype during copyPhysReg #118252
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -421,6 +421,36 @@ void RISCVInstrInfo::copyPhysRegVector( | |
auto MIB = BuildMI(MBB, MBBI, DL, get(Opc), ActualDstReg); | ||
bool UseVMV_V_I = RISCV::getRVVMCOpcode(Opc) == RISCV::VMV_V_I; | ||
bool UseVMV = UseVMV_V_I || RISCV::getRVVMCOpcode(Opc) == RISCV::VMV_V_V; | ||
|
||
// Address https://github.com/llvm/llvm-project/issues/114518 | ||
// Make sure each whole RVVReg move has valid vtype. | ||
unsigned Opcode = MIB->getOpcode(); | ||
if (UseVMV || Opcode == RISCV::VMV1R_V || Opcode == RISCV::VMV2R_V || | ||
Opcode == RISCV::VMV4R_V || Opcode == RISCV::VMV8R_V) { | ||
|
||
// TODO: Data-flow analysis for vtype status could help avoid the | ||
// redundant one. | ||
bool NeedVSETIVLI = true; | ||
|
||
for (auto &CurrMI : MBB) { | ||
unsigned CurrMIOpcode = CurrMI.getOpcode(); | ||
if (CurrMIOpcode == RISCV::PseudoVSETIVLI || | ||
CurrMIOpcode == RISCV::PseudoVSETVLI || | ||
CurrMIOpcode == RISCV::PseudoVSETVLIX0) | ||
NeedVSETIVLI = false; | ||
else if (CurrMI.isInlineAsm()) | ||
NeedVSETIVLI = true; | ||
else if (NeedVSETIVLI && &CurrMI == &*MIB) { | ||
BuildMI(MBB, &*MIB, MIB->getDebugLoc(), get(RISCV::PseudoVSETIVLI)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if there's a vsetvli in an earlier basic block and a later instruction in this basic block that is using the vtype from that vsetvli? Won't this new vsetvli invalidate that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, yes. In this case, it will invalidate the vtype coming from the predecessor basic block. Maybe we could check the following RVV instructions in the same basic block without the explicit vsetvl to ensure there is a vtype from another basic block. |
||
.addReg(RISCV::X0, RegState::Define | RegState::Dead) | ||
.addImm(0) | ||
.addImm(RISCVVType::encodeVTYPE(RISCVII::VLMUL::LMUL_1, 32, false, | ||
false)); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
if (UseVMV) | ||
MIB.addReg(ActualDstReg, RegState::Undef); | ||
if (UseVMV_V_I) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we only check for inline assembly? Don't we need to handle calls?