For now, avoid commuting def MI for copy MI's whose source is not killed. That simply...
authorEvan Cheng <evan.cheng@apple.com>
Mon, 18 Feb 2008 08:40:53 +0000 (08:40 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Mon, 18 Feb 2008 08:40:53 +0000 (08:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47262 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SimpleRegisterCoalescing.cpp

index 17a89086bb6b6e97dc13be9854de0702c3ae69bf..199c89ef55ae57694902862612b674d3d2062805 100644 (file)
@@ -247,6 +247,13 @@ bool SimpleRegisterCoalescing::RemoveCopyByCommutingDef(LiveInterval &IntA,
 
   unsigned CopyIdx = li_->getDefIndex(li_->getInstructionIndex(CopyMI));
 
+  // FIXME: For now, only eliminate the copy by commuting its def is the source
+  // does not live pass the move. Coalescing those copies may end up may simply
+  // end up swapping a live interval for another. That and because usually only
+  // the non-two address operand can be folded can end up pessimizing the code.
+  if (CopyMI->findRegisterUseOperandIdx(IntA.reg, true) != -1)
+    return false;
+
   // BValNo is a value number in B that is defined by a copy from A. 'B3' in
   // the example above.
   LiveInterval::iterator BLR = IntB.FindLiveRangeContaining(CopyIdx);