[PATCH][RegAlloc] Make tryInstructionSplit less aggressive.
Quentin Colombet
qcolombet at apple.com
Mon Dec 23 18:25:21 PST 2013
Thanks Jakob for the quick review!
I'll integrate your suggestions and I'll commit after the break so that I am around in case something goes wrong.
Thanks again.
-Quentin
On Dec 23, 2013, at 3:00 PM, Jakob Stoklund Olesen <stoklund at 2pi.dk> wrote:
>
> On Dec 23, 2013, at 2:35 PM, Quentin Colombet <qcolombet at apple.com> wrote:
>
>> Hi Jakob,
>>
>> Here is the reworked patch.
>>
>> Now the MachineInstr API offers new methods to query the effect of the operand constraints on the register class of a virtual register or on a given register class.
>> The new API is used in MachineRegisterInfo::recomputeRegClass as well as in RAGreedy::tryInstructionSplit.
>
> Thanks, Quentin.
>
> This is looking good.
>
> I think I would prefer to omit the MI::getLargest* functions. You will almost always be looking at multiple instructions, and I’m afraid it can get expensive to call getLargestLegalSuperClass() redundantly for all of them.
>
> The getRegClassConstraintEffect* functions look great.
>
> + const TargetRegisterClass *SuperRC = TRI->getLargestLegalSuperClass(CurRC);
> + // Split around every non-copy instruction if this split will relax
> + // the constraints on the virtual register.
> + // Otherwise, splitting just inserts uncoalescable copies that do not help
> + // the allocation.
> for (unsigned i = 0; i != Uses.size(); ++i) {
> if (const MachineInstr *MI = Indexes->getInstructionFromIndex(Uses[i]))
> - if (MI->isFullCopy()) {
> + if (MI->isFullCopy() ||
> + SuperRC == MI->getLargestRegClassForVReg(VirtReg.reg, TII, TRI, MRI,
> + /* ExploreBundle */ true)) {
>
> Here, I would just pass SuperRC to MI->getRegClassConstraintEffectForVReg() instead.
>
> Also, don’t compare the register classes by equality, but check that the returned register class actually has fewer allocatable registers. See for example GPR/rGPR on ARM. RegisterClassInfo::getNumAllocatableRegs() is very fast.
>
> + if (ExploreBundle && (isBundle() || isBundled())) {
> + MachineBasicBlock::const_instr_iterator I = this;
> + MachineBasicBlock::const_instr_iterator E = getParent()->instr_end();
> + while (CurRC && ++I != E && I->isInsideBundle())
> + // Accumulate the constraints through the instructions.
> + CurRC = I->getRegClassConstraintEffectForVRegImpl(Reg, CurRC, TII, TRI);
> + }
>
> See MIBundleOperands.
>
> Go ahead and commit with those changes.
>
> Thanks,
> /jakob
>
More information about the llvm-commits
mailing list