@@ -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,33 @@ 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)
1174+ auto AddHintIfSuitable = [&](MCPhysReg R,
1175+ const MachineOperand &MO) -> bool {
1176+ // R is a suitable register hint if:
1177+ // * R is one of the source operands.
1178+ // * The register allocator has not suggested any hints and one of the
1179+ // instruction's source operands does not yet have a register
1180+ // allocated for it.
1181+ if (VRM->getPhys (MO.getReg ()) == R ||
1182+ (!VRM->hasPhys (MO.getReg ()) && Hints.empty ())) {
11761183 Hints.push_back (R);
1184+ return true ;
1185+ }
1186+ return false ;
11771187 };
11781188
11791189 switch (InstFlags & AArch64::DestructiveInstTypeMask) {
11801190 default :
11811191 break ;
11821192 case AArch64::DestructiveTernaryCommWithRev:
1183- AddHintIfSuitable (R, Def.getOperand (2 ));
1184- AddHintIfSuitable (R, Def.getOperand (3 ));
1185- AddHintIfSuitable (R, Def.getOperand (4 ));
1193+ AddHintIfSuitable (R, Def.getOperand (2 )) ||
1194+ AddHintIfSuitable (R, Def.getOperand (3 )) ||
1195+ AddHintIfSuitable (R, Def.getOperand (4 ));
11861196 break ;
11871197 case AArch64::DestructiveBinaryComm:
11881198 case AArch64::DestructiveBinaryCommWithRev:
1189- AddHintIfSuitable (R, Def.getOperand (2 ));
1190- AddHintIfSuitable (R, Def.getOperand (3 ));
1199+ AddHintIfSuitable (R, Def.getOperand (2 )) ||
1200+ AddHintIfSuitable (R, Def.getOperand (3 ));
11911201 break ;
11921202 case AArch64::DestructiveBinary:
11931203 case AArch64::DestructiveBinaryImm:
@@ -1198,8 +1208,7 @@ bool AArch64RegisterInfo::getRegAllocationHints(
11981208 }
11991209
12001210 if (Hints.size ())
1201- return TargetRegisterInfo::getRegAllocationHints (VirtReg, Order, Hints,
1202- MF, VRM);
1211+ return ConsiderOnlyHints;
12031212 }
12041213
12051214 if (!ST.hasSME () || !ST.isStreaming ())
0 commit comments