[CodeGen] Make the TwoAddressInstructionPass check if the instruction is commutable before calling findCommutedOpIndices for every operand. Also make sure the operand is a register before each call to save some work on commutable instructions that might have an operand.
llvm-svn: 281158
This commit is contained in:
@@ -1171,6 +1171,9 @@ bool TwoAddressInstructionPass::tryInstructionCommute(MachineInstr *MI,
|
|||||||
unsigned BaseOpIdx,
|
unsigned BaseOpIdx,
|
||||||
bool BaseOpKilled,
|
bool BaseOpKilled,
|
||||||
unsigned Dist) {
|
unsigned Dist) {
|
||||||
|
if (!MI->isCommutable())
|
||||||
|
return false;
|
||||||
|
|
||||||
unsigned DstOpReg = MI->getOperand(DstOpIdx).getReg();
|
unsigned DstOpReg = MI->getOperand(DstOpIdx).getReg();
|
||||||
unsigned BaseOpReg = MI->getOperand(BaseOpIdx).getReg();
|
unsigned BaseOpReg = MI->getOperand(BaseOpIdx).getReg();
|
||||||
unsigned OpsNum = MI->getDesc().getNumOperands();
|
unsigned OpsNum = MI->getDesc().getNumOperands();
|
||||||
@@ -1180,7 +1183,7 @@ bool TwoAddressInstructionPass::tryInstructionCommute(MachineInstr *MI,
|
|||||||
// and OtherOpIdx are commutable, it does not really search for
|
// and OtherOpIdx are commutable, it does not really search for
|
||||||
// other commutable operands and does not change the values of passed
|
// other commutable operands and does not change the values of passed
|
||||||
// variables.
|
// variables.
|
||||||
if (OtherOpIdx == BaseOpIdx ||
|
if (OtherOpIdx == BaseOpIdx || !MI->getOperand(OtherOpIdx).isReg() ||
|
||||||
!TII->findCommutedOpIndices(*MI, BaseOpIdx, OtherOpIdx))
|
!TII->findCommutedOpIndices(*MI, BaseOpIdx, OtherOpIdx))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user