diff options
author | Craig Topper <craig.topper@gmail.com> | 2016-09-11 06:00:15 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2016-09-11 06:00:15 +0000 |
commit | 1f81deee1fb8bbdece6245bc898ac08ab941b55c (patch) | |
tree | ee9a37bed15bc03fa1fad0d99f8cfad5cbc512f1 /llvm | |
parent | 3639cda748bdd6636627fd9c922150a33281a814 (diff) | |
download | bcm5719-llvm-1f81deee1fb8bbdece6245bc898ac08ab941b55c.tar.gz bcm5719-llvm-1f81deee1fb8bbdece6245bc898ac08ab941b55c.zip |
[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
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/CodeGen/TwoAddressInstructionPass.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp index 16ae90de66e..704f596e56f 100644 --- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp +++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp @@ -1171,6 +1171,9 @@ bool TwoAddressInstructionPass::tryInstructionCommute(MachineInstr *MI, unsigned BaseOpIdx, bool BaseOpKilled, unsigned Dist) { + if (!MI->isCommutable()) + return false; + unsigned DstOpReg = MI->getOperand(DstOpIdx).getReg(); unsigned BaseOpReg = MI->getOperand(BaseOpIdx).getReg(); unsigned OpsNum = MI->getDesc().getNumOperands(); @@ -1180,7 +1183,7 @@ bool TwoAddressInstructionPass::tryInstructionCommute(MachineInstr *MI, // and OtherOpIdx are commutable, it does not really search for // other commutable operands and does not change the values of passed // variables. - if (OtherOpIdx == BaseOpIdx || + if (OtherOpIdx == BaseOpIdx || !MI->getOperand(OtherOpIdx).isReg() || !TII->findCommutedOpIndices(*MI, BaseOpIdx, OtherOpIdx)) continue; |