Fix PR9962 by properly constraining register classes in RemoveCopyByCommutingDef(). This

actually fixes most of the VerifyCoalescing failures in test-suite.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131768 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Cameron Zwarich 2011-05-20 23:25:36 +00:00
parent 43299776d7
commit 345968c82d

View File

@ -430,6 +430,10 @@ bool SimpleRegisterCoalescing::RemoveCopyByCommutingDef(const CoalescerPair &CP,
MachineInstr *NewMI = tii_->commuteInstruction(DefMI);
if (!NewMI)
return false;
if (TargetRegisterInfo::isVirtualRegister(IntA.reg) &&
TargetRegisterInfo::isVirtualRegister(IntB.reg) &&
!mri_->constrainRegClass(IntB.reg, mri_->getRegClass(IntA.reg)))
return false;
if (NewMI != DefMI) {
li_->ReplaceMachineInstrInMaps(DefMI, NewMI);
MBB->insert(DefMI, NewMI);