@@ -177,10 +177,15 @@ class EmitContext {
177177 Register AgnosticZABufferPtr = AArch64::NoRegister;
178178};
179179
180+ // / Checks if \p State is a legal edge bundle state. For a state to be a legal
181+ // / bundle state, it must be possible to transition from it to any other bundle
182+ // / state without losing any ZA state. This is the case for ACTIVE/LOCAL_SAVED,
183+ // / as you can transition between those states by saving/restoring ZA. The OFF
184+ // / state would not be legal, as transitioning to it drops the content of ZA.
180185static bool isLegalEdgeBundleZAState (ZAState State) {
181186 switch (State) {
182- case ZAState::ACTIVE:
183- case ZAState::LOCAL_SAVED:
187+ case ZAState::ACTIVE: // ZA state within the accumulator/ZT0.
188+ case ZAState::LOCAL_SAVED: // ZA state is saved on the stack.
184189 return true ;
185190 default :
186191 return false ;
@@ -463,34 +468,33 @@ void MachineSMEABI::propagateDesiredStates(FunctionInfo &FnInfo,
463468
464469 while (!Worklist.empty ()) {
465470 MachineBasicBlock *MBB = Worklist.pop_back_val ();
466- auto &BlockInfo = FnInfo.Blocks [MBB->getNumber ()];
471+ BlockInfo &Block = FnInfo.Blocks [MBB->getNumber ()];
467472
468473 // Pick a legal edge bundle state that matches the majority of
469474 // predecessors/successors.
470475 int StateCounts[ZAState::NUM_ZA_STATE] = {0 };
471476 for (MachineBasicBlock *PredOrSucc :
472477 Forwards ? predecessors (MBB) : successors (MBB)) {
473- auto &PredOrSuccBlockInfo = FnInfo.Blocks [PredOrSucc->getNumber ()];
474- auto ZAState = GetBlockState (PredOrSuccBlockInfo , !Forwards);
478+ BlockInfo &PredOrSuccBlock = FnInfo.Blocks [PredOrSucc->getNumber ()];
479+ ZAState ZAState = GetBlockState (PredOrSuccBlock , !Forwards);
475480 if (isLegalEdgeBundleZAState (ZAState))
476481 StateCounts[ZAState]++;
477482 }
478483
479484 ZAState PropagatedState = ZAState (max_element (StateCounts) - StateCounts);
480- auto &CurrentState = GetBlockState (BlockInfo , Forwards);
485+ ZAState &CurrentState = GetBlockState (Block , Forwards);
481486 if (PropagatedState != CurrentState) {
482487 CurrentState = PropagatedState;
483- auto &OtherState = GetBlockState (BlockInfo , !Forwards);
488+ ZAState &OtherState = GetBlockState (Block , !Forwards);
484489 // Propagate to the incoming/outgoing state if that is also "ANY".
485490 if (OtherState == ZAState::ANY)
486491 OtherState = PropagatedState;
487492 // Push any successors/predecessors that may need updating to the
488493 // worklist.
489494 for (MachineBasicBlock *SuccOrPred :
490495 Forwards ? successors (MBB) : predecessors (MBB)) {
491- auto &SuccOrPredBlockInfo = FnInfo.Blocks [SuccOrPred->getNumber ()];
492- if (!isLegalEdgeBundleZAState (
493- GetBlockState (SuccOrPredBlockInfo, Forwards)))
496+ BlockInfo &SuccOrPredBlock = FnInfo.Blocks [SuccOrPred->getNumber ()];
497+ if (!isLegalEdgeBundleZAState (GetBlockState (SuccOrPredBlock, Forwards)))
494498 Worklist.push_back (SuccOrPred);
495499 }
496500 }
0 commit comments