File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -1143,6 +1143,16 @@ bool RISCVVLOptimizer::isCandidate(const MachineInstr &MI) const {
1143
1143
if (MI.getNumDefs () != 1 )
1144
1144
return false ;
1145
1145
1146
+ unsigned VLOpNum = RISCVII::getVLOpNum (Desc);
1147
+ const MachineOperand &VLOp = MI.getOperand (VLOpNum);
1148
+
1149
+ // If the VL is 1, then there is no need to reduce it. This is an
1150
+ // optimization, not needed to preserve correctness.
1151
+ if (VLOp.isImm () && VLOp.getImm () == 1 ) {
1152
+ LLVM_DEBUG (dbgs () << " Not a candidate because VL is already 1\n " );
1153
+ return false ;
1154
+ }
1155
+
1146
1156
if (MI.mayRaiseFPException ()) {
1147
1157
LLVM_DEBUG (dbgs () << " Not a candidate because may raise FP exception\n " );
1148
1158
return false ;
@@ -1335,8 +1345,6 @@ bool RISCVVLOptimizer::runOnMachineFunction(MachineFunction &MF) {
1335
1345
continue ;
1336
1346
1337
1347
MachineInstr *DefMI = MRI->getVRegDef (Op.getReg ());
1338
- if (!isCandidate (*DefMI))
1339
- continue ;
1340
1348
1341
1349
if (IgnoreSameBlock && DefMI->getParent () == MI.getParent ())
1342
1350
continue ;
@@ -1368,7 +1376,8 @@ bool RISCVVLOptimizer::runOnMachineFunction(MachineFunction &MF) {
1368
1376
while (!Worklist.empty ()) {
1369
1377
assert (MadeChange);
1370
1378
MachineInstr &MI = *Worklist.pop_back_val ();
1371
- assert (isCandidate (MI));
1379
+ if (!isCandidate (MI))
1380
+ continue ;
1372
1381
if (!tryReduceVL (MI))
1373
1382
continue ;
1374
1383
PushOperands (MI, /* IgnoreSameBlock*/ false );
You can’t perform that action at this time.
0 commit comments