[llvm] r281158 - [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.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 10 23:00:16 PDT 2016
Author: ctopper
Date: Sun Sep 11 01:00:15 2016
New Revision: 281158
URL: http://llvm.org/viewvc/llvm-project?rev=281158&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp
Modified: llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp?rev=281158&r1=281157&r2=281158&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp (original)
+++ llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp Sun Sep 11 01:00:15 2016
@@ -1171,6 +1171,9 @@ bool TwoAddressInstructionPass::tryInstr
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::tryInstr
// 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;
More information about the llvm-commits
mailing list