@@ -4332,13 +4332,9 @@ static bool expandFillPPRFromZPRSlotPseudo(
4332
4332
UsedRegs, ZPRRegs, SpillSlots.ZPRSpillFI );
4333
4333
4334
4334
Register PredReg = AArch64::NoRegister;
4335
- std::optional<ScopedScavengeOrSpill> FindPPR3bReg;
4336
- if (AArch64::PPR_3bRegClass.contains (MI.getOperand (0 ).getReg ()))
4337
- PredReg = MI.getOperand (0 ).getReg ();
4338
- else
4339
- FindPPR3bReg.emplace (MF, MBB, MachineBasicBlock::iterator (MI), PredReg,
4340
- AArch64::P0, AArch64::PPR_3bRegClass, UsedRegs,
4341
- PPR3bRegs, SpillSlots.PPRSpillFI );
4335
+ ScopedScavengeOrSpill FindPPR3bReg (
4336
+ MF, MBB, MachineBasicBlock::iterator (MI), PredReg, AArch64::P0,
4337
+ AArch64::PPR_3bRegClass, UsedRegs, PPR3bRegs, SpillSlots.PPRSpillFI );
4342
4338
4343
4339
// Elide NZCV spills if we know it is not used.
4344
4340
Register NZCVSaveReg = AArch64::NoRegister;
@@ -4350,8 +4346,7 @@ static bool expandFillPPRFromZPRSlotPseudo(
4350
4346
SpillSlots.GPRSpillFI );
4351
4347
4352
4348
#ifndef NDEBUG
4353
- bool Spilled = FindZPRReg.hasSpilled () ||
4354
- (FindPPR3bReg && FindPPR3bReg->hasSpilled ()) ||
4349
+ bool Spilled = FindZPRReg.hasSpilled () || FindPPR3bReg.hasSpilled () ||
4355
4350
(FindGPRReg && FindGPRReg->hasSpilled ());
4356
4351
bool InPrologueOrEpilogue = MI.getFlag (MachineInstr::FrameSetup) ||
4357
4352
MI.getFlag (MachineInstr::FrameDestroy);
@@ -4393,7 +4388,7 @@ static bool expandFillPPRFromZPRSlotPseudo(
4393
4388
.getInstr ());
4394
4389
4395
4390
propagateFrameFlags (MI, MachineInstrs);
4396
- return FindPPR3bReg && FindPPR3bReg-> hasSpilled ();
4391
+ return FindPPR3bReg. hasSpilled ();
4397
4392
}
4398
4393
4399
4394
// / Expands all FILL_PPR_FROM_ZPR_SLOT_PSEUDO and SPILL_PPR_TO_ZPR_SLOT_PSEUDO
@@ -4446,6 +4441,7 @@ void AArch64FrameLowering::processFunctionBeforeFrameFinalized(
4446
4441
if (CSRMask)
4447
4442
ScavengeableRegs.clearBitsInMask (CSRMask);
4448
4443
// TODO: Allow reusing callee-saved registers that have been saved.
4444
+ assert (ScavengeableRegs.count () > 0 && " Expected scavengeable registers" );
4449
4445
return ScavengeableRegs;
4450
4446
};
4451
4447
@@ -4471,9 +4467,15 @@ void AArch64FrameLowering::processFunctionBeforeFrameFinalized(
4471
4467
4472
4468
EmergencyStackSlots SpillSlots;
4473
4469
for (MachineBasicBlock &MBB : MF) {
4470
+ // In the case we had to spill a predicate (in the range p0-p7) to reload
4471
+ // a predicate (>= p8), additional spill/fill pseudos will be created.
4472
+ // These need an additional expansion pass. Note: There will only be at
4473
+ // most two expansion passes, as spilling/filling a predicate in the range
4474
+ // p0-p7 never requires spilling another predicate.
4474
4475
for (int Pass = 0 ; Pass < 2 ; Pass++) {
4475
4476
bool HasPPRSpills = expandSMEPPRToZPRSpillPseudos (
4476
4477
MBB, TRI, ZPRRegs, PPR3bRegs, GPRRegs, SpillSlots);
4478
+ assert ((Pass == 0 || !HasPPRSpills) && " Did not expect PPR spills" );
4477
4479
if (!HasPPRSpills)
4478
4480
break ;
4479
4481
}
@@ -5524,9 +5526,8 @@ void AArch64FrameLowering::emitRemarks(
5524
5526
if (MFI.getStackID (FrameIdx) == TargetStackID::ScalableVector) {
5525
5527
// SPILL_PPR_TO_ZPR_SLOT_PSEUDO and FILL_PPR_FROM_ZPR_SLOT_PSEUDO
5526
5528
// spill/fill the predicate as a data vector (so are an FPR acess).
5527
- if (!is_contained ({AArch64::SPILL_PPR_TO_ZPR_SLOT_PSEUDO,
5528
- AArch64::FILL_PPR_FROM_ZPR_SLOT_PSEUDO},
5529
- MI.getOpcode ()) &&
5529
+ if (MI.getOpcode () != AArch64::SPILL_PPR_TO_ZPR_SLOT_PSEUDO &&
5530
+ MI.getOpcode () != AArch64::FILL_PPR_FROM_ZPR_SLOT_PSEUDO &&
5530
5531
AArch64::PPRRegClass.contains (MI.getOperand (0 ).getReg ()))
5531
5532
RegTy = StackAccess::PPR;
5532
5533
else
0 commit comments