summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CriticalAntiDepBreaker.cpp
diff options
context:
space:
mode:
authorJim Grosbach <grosbach@apple.com>2010-01-06 22:21:25 +0000
committerJim Grosbach <grosbach@apple.com>2010-01-06 22:21:25 +0000
commit80c2b0d9efc951b23f90a3cf12b9853177994961 (patch)
tree9e68bafd66f0a90916184541db40b106edc01ed9 /lib/CodeGen/CriticalAntiDepBreaker.cpp
parent130063207de67ecb36e5c80b9118f3c0817fbc6f (diff)
downloadllvm-80c2b0d9efc951b23f90a3cf12b9853177994961.tar.gz
llvm-80c2b0d9efc951b23f90a3cf12b9853177994961.tar.bz2
llvm-80c2b0d9efc951b23f90a3cf12b9853177994961.tar.xz
Anti-dependency breaking needs to be careful regarding instructions with
multiple register definitions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92864 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CriticalAntiDepBreaker.cpp')
-rw-r--r--lib/CodeGen/CriticalAntiDepBreaker.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/CodeGen/CriticalAntiDepBreaker.cpp b/lib/CodeGen/CriticalAntiDepBreaker.cpp
index e5d68a6cb8..056e2d5b01 100644
--- a/lib/CodeGen/CriticalAntiDepBreaker.cpp
+++ b/lib/CodeGen/CriticalAntiDepBreaker.cpp
@@ -288,7 +288,8 @@ void CriticalAntiDepBreaker::ScanInstruction(MachineInstr *MI,
}
unsigned
-CriticalAntiDepBreaker::findSuitableFreeRegister(unsigned AntiDepReg,
+CriticalAntiDepBreaker::findSuitableFreeRegister(MachineInstr *MI,
+ unsigned AntiDepReg,
unsigned LastNewReg,
const TargetRegisterClass *RC)
{
@@ -301,6 +302,10 @@ CriticalAntiDepBreaker::findSuitableFreeRegister(unsigned AntiDepReg,
// an anti-dependence with this AntiDepReg, because that would
// re-introduce that anti-dependence.
if (NewReg == LastNewReg) continue;
+ // If the instruction already has a def of the NewReg, it's not suitable.
+ // For example, Instruction with multiple definitions can result in this
+ // condition.
+ if (MI->modifiesRegister(NewReg, TRI)) continue;
// If NewReg is dead and NewReg's most recent def is not before
// AntiDepReg's kill, it's safe to replace AntiDepReg with NewReg.
assert(((KillIndices[AntiDepReg] == ~0u) != (DefIndices[AntiDepReg] == ~0u))
@@ -496,7 +501,7 @@ BreakAntiDependencies(std::vector<SUnit>& SUnits,
// TODO: Instead of picking the first free register, consider which might
// be the best.
if (AntiDepReg != 0) {
- if (unsigned NewReg = findSuitableFreeRegister(AntiDepReg,
+ if (unsigned NewReg = findSuitableFreeRegister(MI, AntiDepReg,
LastNewReg[AntiDepReg],
RC)) {
DEBUG(dbgs() << "Breaking anti-dependence edge on "