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 {
11431143 if (MI.getNumDefs () != 1 )
11441144 return false ;
11451145
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+
11461156 if (MI.mayRaiseFPException ()) {
11471157 LLVM_DEBUG (dbgs () << " Not a candidate because may raise FP exception\n " );
11481158 return false ;
@@ -1335,8 +1345,6 @@ bool RISCVVLOptimizer::runOnMachineFunction(MachineFunction &MF) {
13351345 continue ;
13361346
13371347 MachineInstr *DefMI = MRI->getVRegDef (Op.getReg ());
1338- if (!isCandidate (*DefMI))
1339- continue ;
13401348
13411349 if (IgnoreSameBlock && DefMI->getParent () == MI.getParent ())
13421350 continue ;
@@ -1368,7 +1376,8 @@ bool RISCVVLOptimizer::runOnMachineFunction(MachineFunction &MF) {
13681376 while (!Worklist.empty ()) {
13691377 assert (MadeChange);
13701378 MachineInstr &MI = *Worklist.pop_back_val ();
1371- assert (isCandidate (MI));
1379+ if (!isCandidate (MI))
1380+ continue ;
13721381 if (!tryReduceVL (MI))
13731382 continue ;
13741383 PushOperands (MI, /* IgnoreSameBlock*/ false );
You can’t perform that action at this time.
0 commit comments