aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/RegAllocLocal.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2008-07-10 07:35:43 +0000
committerEvan Cheng <evan.cheng@apple.com>2008-07-10 07:35:43 +0000
commitef0732d25a9882c947984ae3f2afbef5463ba00f (patch)
treefb57684794d4837a901af952c17b790c9ab2cc69 /lib/CodeGen/RegAllocLocal.cpp
parent5dcc41f5b3daf6ef7097f169767291ff9cd0dd0b (diff)
- Change the horrible N^2 isRegReDefinedByTwoAddr. Now callers must supply the operand index of def machineoperand and at most one full scan of non-implicit operands is needed.
- Change local register allocator to use the new isRegReDefinedByTwoAddr instead of reinventing the wheel. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53394 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegAllocLocal.cpp')
-rw-r--r--lib/CodeGen/RegAllocLocal.cpp20
1 files changed, 5 insertions, 15 deletions
diff --git a/lib/CodeGen/RegAllocLocal.cpp b/lib/CodeGen/RegAllocLocal.cpp
index c1dacb6cb8..d3e38d043a 100644
--- a/lib/CodeGen/RegAllocLocal.cpp
+++ b/lib/CodeGen/RegAllocLocal.cpp
@@ -604,25 +604,15 @@ void RALocal::ComputeLocalLiveness(MachineBasicBlock& MBB) {
if (last != LastUseDef.end()) {
// Check if this is a two address instruction. If so, then
// the def does not kill the use.
- if (last->second.first == I) {
- bool isTwoAddr = false;
- for (unsigned j = i+1, je = I->getDesc().getNumOperands();
- j < je; ++j) {
- const MachineOperand &MO2 = I->getOperand(j);
- if (MO2.isRegister() && MO2.isUse() &&
- MO2.getReg() == MO.getReg() &&
- I->getDesc().getOperandConstraint(j, TOI::TIED_TO) == (int)i)
- isTwoAddr = true;
- }
-
- if (isTwoAddr) continue;
- }
+ if (last->second.first == I &&
+ I->isRegReDefinedByTwoAddr(MO.getReg(), i))
+ continue;
MachineOperand& lastUD =
last->second.first->getOperand(last->second.second);
if (lastUD.isDef())
lastUD.setIsDead(true);
- else if (lastUD.isUse())
+ else
lastUD.setIsKill(true);
}
@@ -677,7 +667,7 @@ void RALocal::ComputeLocalLiveness(MachineBasicBlock& MBB) {
if (isPhysReg || !usedOutsideBlock) {
if (MO.isUse())
MO.setIsKill(true);
- else if (MI->getOperand(idx).isDef())
+ else
MO.setIsDead(true);
}
}