@@ -1157,6 +1157,9 @@ bool AArch64RegisterInfo::getRegAllocationHints(
11571157 // a movprfx.
11581158 const TargetRegisterClass *RegRC = MRI.getRegClass (VirtReg);
11591159 if (AArch64::ZPRRegClass.hasSubClassEq (RegRC)) {
1160+ bool ConsiderOnlyHints = TargetRegisterInfo::getRegAllocationHints (
1161+ VirtReg, Order, Hints, MF, VRM);
1162+
11601163 for (const MachineOperand &DefOp : MRI.def_operands (VirtReg)) {
11611164 const MachineInstr &Def = *DefOp.getParent ();
11621165 if (DefOp.isImplicit () ||
@@ -1168,26 +1171,28 @@ bool AArch64RegisterInfo::getRegAllocationHints(
11681171 TII->get (AArch64::getSVEPseudoMap (Def.getOpcode ())).TSFlags ;
11691172
11701173 for (MCPhysReg R : Order) {
1171- auto AddHintIfSuitable = [&](MCPhysReg R, const MachineOperand &MO) {
1172- // R is a suitable register hint if there exists an operand for the
1173- // instruction that is not yet allocated a register or if R matches
1174- // one of the other source operands.
1175- if (!VRM->hasPhys (MO.getReg ()) || VRM->getPhys (MO.getReg ()) == R)
1176- Hints.push_back (R);
1174+ auto AddHintIfSuitable = [&](MCPhysReg R,
1175+ const MachineOperand &MO) -> bool {
1176+ // R is a suitable register hint if R can reuse one of the other
1177+ // source operands.
1178+ if (VRM->getPhys (MO.getReg ()) != R)
1179+ return false ;
1180+ Hints.push_back (R);
1181+ return true ;
11771182 };
11781183
11791184 switch (InstFlags & AArch64::DestructiveInstTypeMask) {
11801185 default :
11811186 break ;
11821187 case AArch64::DestructiveTernaryCommWithRev:
1183- AddHintIfSuitable (R, Def.getOperand (2 ));
1184- AddHintIfSuitable (R, Def.getOperand (3 ));
1185- AddHintIfSuitable (R, Def.getOperand (4 ));
1188+ AddHintIfSuitable (R, Def.getOperand (2 )) ||
1189+ AddHintIfSuitable (R, Def.getOperand (3 )) ||
1190+ AddHintIfSuitable (R, Def.getOperand (4 ));
11861191 break ;
11871192 case AArch64::DestructiveBinaryComm:
11881193 case AArch64::DestructiveBinaryCommWithRev:
1189- AddHintIfSuitable (R, Def.getOperand (2 ));
1190- AddHintIfSuitable (R, Def.getOperand (3 ));
1194+ AddHintIfSuitable (R, Def.getOperand (2 )) ||
1195+ AddHintIfSuitable (R, Def.getOperand (3 ));
11911196 break ;
11921197 case AArch64::DestructiveBinary:
11931198 case AArch64::DestructiveBinaryImm:
@@ -1198,8 +1203,7 @@ bool AArch64RegisterInfo::getRegAllocationHints(
11981203 }
11991204
12001205 if (Hints.size ())
1201- return TargetRegisterInfo::getRegAllocationHints (VirtReg, Order, Hints,
1202- MF, VRM);
1206+ return ConsiderOnlyHints;
12031207 }
12041208
12051209 if (!ST.hasSME () || !ST.isStreaming ())
0 commit comments