Skip to content

Commit b49d910

Browse files
fixup! respond to some more comments
1 parent 6335561 commit b49d910

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
@@ -1366,29 +1366,31 @@ static bool isVectorOpUsedAsScalarOp(MachineOperand &MO) {
13661366
}
13671367
}
13681368

1369-
static bool safeToPropgateVL(const MachineInstr &MI) {
1369+
/// Return true if MI may read elements past VL.
1370+
static bool mayReadPastVL(const MachineInstr &MI) {
13701371
const RISCVVPseudosTable::PseudoInfo *RVV =
13711372
RISCVVPseudosTable::getPseudoInfo(MI.getOpcode());
13721373
if (!RVV)
1373-
return false;
1374+
return true;
13741375

13751376
switch (RVV->BaseInstr) {
1376-
// vslidedown instructions may use the higher part of the input operand beyond
1377-
// the VL.
1377+
// vslidedown instructions may read elements past VL. They are handled
1378+
// according to current tail policy.
13781379
case RISCV::VSLIDEDOWN_VI:
13791380
case RISCV::VSLIDEDOWN_VX:
13801381
case RISCV::VSLIDE1DOWN_VX:
13811382
case RISCV::VFSLIDE1DOWN_VF:
13821383

1383-
// vrgather instructions may index beyond the VL.
1384+
// vrgather instructions may read the source vector at any index < VLMAX,
1385+
// regardless of VL.
13841386
case RISCV::VRGATHER_VI:
13851387
case RISCV::VRGATHER_VV:
13861388
case RISCV::VRGATHER_VX:
13871389
case RISCV::VRGATHEREI16_VV:
1388-
return false;
1390+
return true;
13891391

13901392
default:
1391-
return true;
1393+
return false;
13921394
}
13931395
}
13941396

@@ -1443,6 +1445,7 @@ bool RISCVVLOptimizer::tryReduceVL(MachineInstr &OrigMI) {
14431445
while (!Worklist.empty()) {
14441446
MachineInstr &MI = *Worklist.pop_back_val();
14451447
LLVM_DEBUG(dbgs() << "Try reduce VL for " << MI << "\n");
1448+
14461449
std::optional<Register> CommonVL;
14471450
bool CanReduceVL = true;
14481451
for (auto &UserOp : MRI->use_operands(MI.getOperand(0).getReg())) {
@@ -1461,7 +1464,7 @@ bool RISCVVLOptimizer::tryReduceVL(MachineInstr &OrigMI) {
14611464
continue;
14621465
}
14631466

1464-
if (!safeToPropgateVL(UserMI)) {
1467+
if (mayReadPastVL(UserMI)) {
14651468
LLVM_DEBUG(dbgs() << " Abort due to used by unsafe instruction\n");
14661469
CanReduceVL = false;
14671470
break;

0 commit comments

Comments
 (0)