When deleting a phi cycle after looking through copies, constrain the register
authorCameron Zwarich <zwarich@apple.com>
Mon, 17 Oct 2011 21:54:46 +0000 (21:54 +0000)
committerCameron Zwarich <zwarich@apple.com>
Mon, 17 Oct 2011 21:54:46 +0000 (21:54 +0000)
to match its final use.

With this change, all of test-suite compiles for Thumb2 with -verify-coalescing
enabled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142287 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/OptimizePHIs.cpp

index c05be130ec6191f8d92da2c79aca9100138fe0bb..85fa04180088f1a74339576174240a617c497cfa 100644 (file)
@@ -165,7 +165,11 @@ bool OptimizePHIs::OptimizeBB(MachineBasicBlock &MBB) {
     InstrSet PHIsInCycle;
     if (IsSingleValuePHICycle(MI, SingleValReg, PHIsInCycle) &&
         SingleValReg != 0) {
-      MRI->replaceRegWith(MI->getOperand(0).getReg(), SingleValReg);
+      unsigned OldReg = MI->getOperand(0).getReg();
+      if (!MRI->constrainRegClass(SingleValReg, MRI->getRegClass(OldReg)))
+        continue;
+
+      MRI->replaceRegWith(OldReg, SingleValReg);
       MI->eraseFromParent();
       ++NumPHICycles;
       Changed = true;