forked from OSchip/llvm-project
[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
This commit is contained in:
parent
8c2bf45da9
commit
7600794dde
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue