diff options
| author | Evan Cheng <evan.cheng@apple.com> | 2009-07-20 21:16:08 +0000 |
|---|---|---|
| committer | Evan Cheng <evan.cheng@apple.com> | 2009-07-20 21:16:08 +0000 |
| commit | 57106d6dc01b33c8e129dfc75c88fa5117bc1730 (patch) | |
| tree | 7becfbacd47153101e1c265519bd19b5151aac3d /llvm/lib | |
| parent | bf04f98c1f971c6362a26762e8c813228c4b8b43 (diff) | |
| download | bcm5719-llvm-57106d6dc01b33c8e129dfc75c88fa5117bc1730.tar.gz bcm5719-llvm-57106d6dc01b33c8e129dfc75c88fa5117bc1730.zip | |
Use TII->findCommutedOpIndices to find the commute operands (rather than guessing).
llvm-svn: 76472
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/TwoAddressInstructionPass.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp index 83468d9273d..ebdf9cf4468 100644 --- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp +++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp @@ -879,10 +879,14 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) { // so, swap the B and C operands. This makes the live ranges of A // and C joinable. // FIXME: This code also works for A := B op C instructions. - if (TID.isCommutable() && mi->getNumOperands() >= 3) { - assert(mi->getOperand(3-si).isReg() && - "Not a proper commutative instruction!"); - unsigned regC = mi->getOperand(3-si).getReg(); + unsigned SrcOp1, SrcOp2; + if (TID.isCommutable() && mi->getNumOperands() >= 3 && + TII->findCommutedOpIndices(mi, SrcOp1, SrcOp2)) { + unsigned regC = 0; + if (si == SrcOp1) + regC = mi->getOperand(SrcOp2).getReg(); + else if (si == SrcOp2) + regC = mi->getOperand(SrcOp1).getReg(); if (isKilled(*mi, regC, MRI, TII)) { if (CommuteInstruction(mi, mbbi, regB, regC, Dist)) { ++NumCommuted; |

