Skip to content

Commit c957df0

Browse files
authored
[RISCV] Improve some debug messages from RISCVVLOptimizer. NFC (#155524)
Add a MI instruction to the unsupported message. Add message for VL not dominating. Make identation more consistent for the abort messages in this function. Remove new line since printing a MachineInstr already adds a new line.
1 parent 595573d commit c957df0

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,8 @@ bool RISCVVLOptimizer::isCandidate(const MachineInstr &MI) const {
13061306
// TODO: Use a better approach than a white-list, such as adding
13071307
// properties to instructions using something like TSFlags.
13081308
if (!isSupportedInstr(MI)) {
1309-
LLVM_DEBUG(dbgs() << "Not a candidate due to unsupported instruction\n");
1309+
LLVM_DEBUG(dbgs() << "Not a candidate due to unsupported instruction: "
1310+
<< MI);
13101311
return false;
13111312
}
13121313

@@ -1328,14 +1329,14 @@ RISCVVLOptimizer::getMinimumVLForUser(const MachineOperand &UserOp) const {
13281329
const MCInstrDesc &Desc = UserMI.getDesc();
13291330

13301331
if (!RISCVII::hasVLOp(Desc.TSFlags) || !RISCVII::hasSEWOp(Desc.TSFlags)) {
1331-
LLVM_DEBUG(dbgs() << " Abort due to lack of VL, assume that"
1332+
LLVM_DEBUG(dbgs() << " Abort due to lack of VL, assume that"
13321333
" use VLMAX\n");
13331334
return std::nullopt;
13341335
}
13351336

13361337
if (RISCVII::readsPastVL(
13371338
TII->get(RISCV::getRVVMCOpcode(UserMI.getOpcode())).TSFlags)) {
1338-
LLVM_DEBUG(dbgs() << " Abort because used by unsafe instruction\n");
1339+
LLVM_DEBUG(dbgs() << " Abort because used by unsafe instruction\n");
13391340
return std::nullopt;
13401341
}
13411342

@@ -1352,7 +1353,7 @@ RISCVVLOptimizer::getMinimumVLForUser(const MachineOperand &UserOp) const {
13521353
RISCVII::isFirstDefTiedToFirstUse(UserMI.getDesc()));
13531354
auto DemandedVL = DemandedVLs.lookup(&UserMI);
13541355
if (!DemandedVL || !RISCV::isVLKnownLE(*DemandedVL, VLOp)) {
1355-
LLVM_DEBUG(dbgs() << " Abort because user is passthru in "
1356+
LLVM_DEBUG(dbgs() << " Abort because user is passthru in "
13561357
"instruction with demanded tail\n");
13571358
return std::nullopt;
13581359
}
@@ -1449,7 +1450,7 @@ RISCVVLOptimizer::checkUsers(const MachineInstr &MI) const {
14491450
}
14501451

14511452
bool RISCVVLOptimizer::tryReduceVL(MachineInstr &MI) const {
1452-
LLVM_DEBUG(dbgs() << "Trying to reduce VL for " << MI << "\n");
1453+
LLVM_DEBUG(dbgs() << "Trying to reduce VL for " << MI);
14531454

14541455
unsigned VLOpNum = RISCVII::getVLOpNum(MI.getDesc());
14551456
MachineOperand &VLOp = MI.getOperand(VLOpNum);
@@ -1469,13 +1470,13 @@ bool RISCVVLOptimizer::tryReduceVL(MachineInstr &MI) const {
14691470
"Expected VL to be an Imm or virtual Reg");
14701471

14711472
if (!RISCV::isVLKnownLE(*CommonVL, VLOp)) {
1472-
LLVM_DEBUG(dbgs() << " Abort due to CommonVL not <= VLOp.\n");
1473+
LLVM_DEBUG(dbgs() << " Abort due to CommonVL not <= VLOp.\n");
14731474
return false;
14741475
}
14751476

14761477
if (CommonVL->isIdenticalTo(VLOp)) {
14771478
LLVM_DEBUG(
1478-
dbgs() << " Abort due to CommonVL == VLOp, no point in reducing.\n");
1479+
dbgs() << " Abort due to CommonVL == VLOp, no point in reducing.\n");
14791480
return false;
14801481
}
14811482

@@ -1486,8 +1487,10 @@ bool RISCVVLOptimizer::tryReduceVL(MachineInstr &MI) const {
14861487
return true;
14871488
}
14881489
const MachineInstr *VLMI = MRI->getVRegDef(CommonVL->getReg());
1489-
if (!MDT->dominates(VLMI, &MI))
1490+
if (!MDT->dominates(VLMI, &MI)) {
1491+
LLVM_DEBUG(dbgs() << " Abort due to VL not dominating.\n");
14901492
return false;
1493+
}
14911494
LLVM_DEBUG(
14921495
dbgs() << " Reduce VL from " << VLOp << " to "
14931496
<< printReg(CommonVL->getReg(), MRI->getTargetRegisterInfo())

0 commit comments

Comments
 (0)