@@ -943,10 +943,8 @@ RISCVInsertVSETVLI::getInfoForVSETVLI(const MachineInstr &MI) const {
943943 NewInfo.setAVLImm (MI.getOperand (1 ).getImm ());
944944 } else {
945945 assert (MI.getOpcode () == RISCV::PseudoVSETVLI ||
946- MI.getOpcode () == RISCV::PseudoVSETVLIX0 ||
947- MI.getOpcode () == RISCV::PseudoVSETVLIX0X0);
948- if (MI.getOpcode () == RISCV::PseudoVSETVLIX0 ||
949- MI.getOpcode () == RISCV::PseudoVSETVLIX0X0)
946+ MI.getOpcode () == RISCV::PseudoVSETVLIX0);
947+ if (MI.getOpcode () == RISCV::PseudoVSETVLIX0)
950948 NewInfo.setAVLVLMAX ();
951949 else if (MI.getOperand (1 ).isUndef ())
952950 // Otherwise use an AVL of 1 to avoid depending on previous vl.
@@ -1513,21 +1511,12 @@ void RISCVInsertVSETVLI::emitVSETVLIs(MachineBasicBlock &MBB) {
15131511// / this is geared to catch the common case of a fixed length vsetvl in a single
15141512// / block loop when it could execute once in the preheader instead.
15151513void RISCVInsertVSETVLI::doPRE (MachineBasicBlock &MBB) {
1516- // Only works for either one predecessor, or two predecessors if it's a loop
1517- if (MBB.pred_empty () && MBB.pred_size () > 2 )
1518- return ;
1519-
15201514 if (!BlockInfo[MBB.getNumber ()].Pred .isUnknown ())
15211515 return ;
15221516
1523- bool isLoop = false ;
1524-
15251517 MachineBasicBlock *UnavailablePred = nullptr ;
15261518 VSETVLIInfo AvailableInfo;
1527- MachineBasicBlock *PreviousPred = nullptr ;
15281519 for (MachineBasicBlock *P : MBB.predecessors ()) {
1529- isLoop |= (P == &MBB);
1530-
15311520 const VSETVLIInfo &PredInfo = BlockInfo[P->getNumber ()].Exit ;
15321521 if (PredInfo.isUnknown ()) {
15331522 if (UnavailablePred)
@@ -1536,24 +1525,8 @@ void RISCVInsertVSETVLI::doPRE(MachineBasicBlock &MBB) {
15361525 } else if (!AvailableInfo.isValid ()) {
15371526 AvailableInfo = PredInfo;
15381527 } else if (AvailableInfo != PredInfo) {
1539- if (!isLoop)
1540- return ;
1541-
1542- DemandedFields PREDemands;
1543- PREDemands.demandVTYPE ();
1544-
1545- if (!PredInfo.isCompatible (PREDemands, AvailableInfo, LIS))
1546- return ;
1547-
1548- // States are VTYPE-compatible, prefer the more general state
1549- // Choose VLMAX over immediate when both are tail-agnostic
1550- if (PredInfo.hasAVLVLMAX () && AvailableInfo.hasAVLImm ()) {
1551- AvailableInfo = PredInfo;
1552- UnavailablePred = PreviousPred;
1553- }
1528+ return ;
15541529 }
1555-
1556- PreviousPred = P;
15571530 }
15581531
15591532 // Unreachable, single pred, or full redundancy. Note that FRE is handled by
@@ -1570,7 +1543,7 @@ void RISCVInsertVSETVLI::doPRE(MachineBasicBlock &MBB) {
15701543 return ;
15711544
15721545 // Critical edge - TODO: consider splitting?
1573- if (UnavailablePred->succ_size () != 1 && !isLoop )
1546+ if (UnavailablePred->succ_size () != 1 )
15741547 return ;
15751548
15761549 // If the AVL value is a register (other than our VLMAX sentinel),
@@ -1598,49 +1571,21 @@ void RISCVInsertVSETVLI::doPRE(MachineBasicBlock &MBB) {
15981571 VSETVLIInfo OldInfo = BlockInfo[MBB.getNumber ()].Pred ;
15991572 VSETVLIInfo CurInfo = AvailableInfo;
16001573 int TransitionsRemoved = 0 ;
1601-
1602- LLVM_DEBUG (dbgs () << " PRE VSETVLI from " << MBB.getName () << " to "
1603- << UnavailablePred->getName () << " \n "
1604- << " Old state: " << OldInfo << " \n "
1605- << " New state: " << CurInfo << " \n " );
1606-
16071574 for (const MachineInstr &MI : MBB) {
1608- if (RISCVII::hasSEWOp (MI.getDesc ().TSFlags ))
1609- if (!hasUndefinedPassthru (MI))
1610- return ; // Unsafe to change VL/VTYPE for this loop.
1611-
16121575 const VSETVLIInfo LastInfo = CurInfo;
16131576 const VSETVLIInfo LastOldInfo = OldInfo;
16141577 transferBefore (CurInfo, MI);
16151578 transferBefore (OldInfo, MI);
1616-
1617- LLVM_DEBUG (dbgs () << " PRE VSETVLI 1 from " << MBB.getName () << " to "
1618- << UnavailablePred->getName () << " \n "
1619- << " Old state: " << OldInfo << " \n "
1620- << " New state: " << CurInfo << " \n " );
1621-
16221579 if (CurInfo == LastInfo)
16231580 TransitionsRemoved++;
16241581 if (LastOldInfo == OldInfo)
16251582 TransitionsRemoved--;
16261583 transferAfter (CurInfo, MI);
16271584 transferAfter (OldInfo, MI);
1628-
1629- LLVM_DEBUG (dbgs () << " PRE VSETVLI 2 from " << MBB.getName () << " to "
1630- << UnavailablePred->getName () << " \n "
1631- << " Old state: " << OldInfo << " \n "
1632- << " New state: " << CurInfo << " \n\n " );
1633-
16341585 if (CurInfo == OldInfo)
16351586 // Convergence. All transitions after this must match by construction.
16361587 break ;
16371588 }
1638-
1639- LLVM_DEBUG (dbgs () << " PRE VSETVLI 3 from " << MBB.getName () << " to "
1640- << UnavailablePred->getName () << " \n "
1641- << " Old state: " << OldInfo << " \n "
1642- << " New state: " << CurInfo << " \n " );
1643-
16441589 if (CurInfo != OldInfo || TransitionsRemoved <= 0 )
16451590 // Issues 1 and 2 above
16461591 return ;
0 commit comments