-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[RISCV][VLOpt] Minor worklist invariant cleanup [NFC] #123989
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
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 |
---|---|---|
|
@@ -1189,6 +1189,10 @@ bool RISCVVLOptimizer::isCandidate(const MachineInstr &MI) const { | |
return false; | ||
} | ||
|
||
assert(MI.getOperand(0).isReg() && | ||
isVectorRegClass(MI.getOperand(0).getReg(), MRI) && | ||
"All supported instructions produce a vector register result"); | ||
|
||
LLVM_DEBUG(dbgs() << "Found a candidate for VL reduction: " << MI << "\n"); | ||
return true; | ||
} | ||
|
@@ -1295,9 +1299,6 @@ std::optional<MachineOperand> RISCVVLOptimizer::checkUsers(MachineInstr &MI) { | |
bool RISCVVLOptimizer::tryReduceVL(MachineInstr &MI) { | ||
LLVM_DEBUG(dbgs() << "Trying to reduce VL for " << MI << "\n"); | ||
|
||
if (!isVectorRegClass(MI.getOperand(0).getReg(), MRI)) | ||
return false; | ||
|
||
auto CommonVL = checkUsers(MI); | ||
if (!CommonVL) | ||
return false; | ||
|
@@ -1347,14 +1348,11 @@ bool RISCVVLOptimizer::runOnMachineFunction(MachineFunction &MF) { | |
auto PushOperands = [this, &Worklist](MachineInstr &MI, | ||
bool IgnoreSameBlock) { | ||
for (auto &Op : MI.operands()) { | ||
if (!Op.isReg() || !Op.isUse() || !Op.getReg().isVirtual()) | ||
continue; | ||
|
||
if (!isVectorRegClass(Op.getReg(), MRI)) | ||
if (!Op.isReg() || !Op.isUse() || !Op.getReg().isVirtual() || | ||
!isVectorRegClass(Op.getReg(), MRI)) | ||
continue; | ||
|
||
MachineInstr *DefMI = MRI->getVRegDef(Op.getReg()); | ||
|
||
if (!isCandidate(*DefMI)) | ||
continue; | ||
|
||
|
@@ -1388,6 +1386,7 @@ bool RISCVVLOptimizer::runOnMachineFunction(MachineFunction &MF) { | |
while (!Worklist.empty()) { | ||
assert(MadeChange); | ||
MachineInstr &MI = *Worklist.pop_back_val(); | ||
assert(isCandidate(MI)); | ||
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. Is this assert redundant? isCandidate explicitly blocks insertion to the Worklist in 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. I can drop it if you want. Personally, I find it helpful to have the assertion at the point of extraction from a worklist. This is particular true when there's more than one insert point though - which doesn't apply here. Happy to defer to your preference. 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. We can keep it. It is cheap. |
||
if (!tryReduceVL(MI)) | ||
continue; | ||
PushOperands(MI, /*IgnoreSameBlock*/ false); | ||
|
Uh oh!
There was an error while loading. Please reload this page.