diff options
author | Craig Topper <craig.topper@gmail.com> | 2016-09-11 22:10:42 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2016-09-11 22:10:42 +0000 |
commit | 7600794dde935ab6489a4f239312d3daa4ede096 (patch) | |
tree | 04e3d7fc2bca79ff3dac3cd29ff1492ff6fc164c /llvm/lib/CodeGen/TwoAddressInstructionPass.cpp | |
parent | 8c2bf45da9d830c11dbc577330dfc958608dc78d (diff) | |
download | bcm5719-llvm-7600794dde935ab6489a4f239312d3daa4ede096.tar.gz bcm5719-llvm-7600794dde935ab6489a4f239312d3daa4ede096.zip |
[TwoAddressInstruction] When commuting an instruction don't assume that the destination register is operand 0. Pass it from the caller.
In practice it probably is 0 so this may not be a functional change.
llvm-svn: 281180
Diffstat (limited to 'llvm/lib/CodeGen/TwoAddressInstructionPass.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TwoAddressInstructionPass.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp index 704f596e56f..0f1b2ed994b 100644 --- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp +++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp @@ -109,7 +109,7 @@ class TwoAddressInstructionPass : public MachineFunctionPass { bool isProfitableToCommute(unsigned regA, unsigned regB, unsigned regC, MachineInstr *MI, unsigned Dist); - bool commuteInstruction(MachineInstr *MI, + bool commuteInstruction(MachineInstr *MI, unsigned DstIdx, unsigned RegBIdx, unsigned RegCIdx, unsigned Dist); bool isProfitableToConv3Addr(unsigned RegA, unsigned RegB); @@ -651,6 +651,7 @@ isProfitableToCommute(unsigned regA, unsigned regB, unsigned regC, /// Commute a two-address instruction and update the basic block, distance map, /// and live variables if needed. Return true if it is successful. bool TwoAddressInstructionPass::commuteInstruction(MachineInstr *MI, + unsigned DstIdx, unsigned RegBIdx, unsigned RegCIdx, unsigned Dist) { @@ -671,7 +672,7 @@ bool TwoAddressInstructionPass::commuteInstruction(MachineInstr *MI, // Update source register map. unsigned FromRegC = getMappedReg(RegC, SrcRegMap); if (FromRegC) { - unsigned RegA = MI->getOperand(0).getReg(); + unsigned RegA = MI->getOperand(DstIdx).getReg(); SrcRegMap[RegA] = FromRegC; } @@ -1202,7 +1203,8 @@ bool TwoAddressInstructionPass::tryInstructionCommute(MachineInstr *MI, } // If it's profitable to commute, try to do so. - if (DoCommute && commuteInstruction(MI, BaseOpIdx, OtherOpIdx, Dist)) { + if (DoCommute && commuteInstruction(MI, DstOpIdx, BaseOpIdx, OtherOpIdx, + Dist)) { ++NumCommuted; if (AggressiveCommute) ++NumAggrCommuted; |