diff options
author | Evan Cheng <evan.cheng@apple.com> | 2009-07-10 19:15:51 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2009-07-10 19:15:51 +0000 |
commit | f075943584dc5bada7ef09f89b706a0b5f7e591a (patch) | |
tree | 7cfcbbdfa5926fb1b6100f41f9d772d0c7503449 /llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp | |
parent | 62609a41313f0f6416c9db66e4261690d8f8b0af (diff) | |
download | bcm5719-llvm-f075943584dc5bada7ef09f89b706a0b5f7e591a.tar.gz bcm5719-llvm-f075943584dc5bada7ef09f89b706a0b5f7e591a.zip |
Remove TargetInstrInfo::CommuteChangesDestination and added findCommutedOpIndices which returns the operand indices which are swapped (when applicable). This allows for some code clean up and future enhancements.
llvm-svn: 75264
Diffstat (limited to 'llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp b/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp index 48e6d45713a..d1523f82e9f 100644 --- a/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp +++ b/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp @@ -312,9 +312,23 @@ bool SimpleRegisterCoalescing::RemoveCopyByCommutingDef(LiveInterval &IntA, return false; MachineInstr *DefMI = li_->getInstructionFromIndex(AValNo->def); const TargetInstrDesc &TID = DefMI->getDesc(); - unsigned NewDstIdx; - if (!TID.isCommutable() || - !tii_->CommuteChangesDestination(DefMI, NewDstIdx)) + if (!TID.isCommutable()) + return false; + // If DefMI is a two-address instruction then commuting it will change the + // destination register. + int DefIdx = DefMI->findRegisterDefOperandIdx(IntA.reg); + assert(DefIdx != -1); + unsigned UseOpIdx; + if (!DefMI->isRegTiedToUseOperand(DefIdx, &UseOpIdx)) + return false; + unsigned Op1, Op2, NewDstIdx; + if (!tii_->findCommutedOpIndices(DefMI, Op1, Op2)) + return false; + if (Op1 == UseOpIdx) + NewDstIdx = Op2; + else if (Op2 == UseOpIdx) + NewDstIdx = Op1; + else return false; MachineOperand &NewDstMO = DefMI->getOperand(NewDstIdx); |