aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2009-07-11 00:04:23 +0000
committerEvan Cheng <evan.cheng@apple.com>2009-07-11 00:04:23 +0000
commitb4dfce2dba102eaef3fcb7f52fbb583bbae54a01 (patch)
treef79eceecb06def043b3f07cc25fbf05ec31b40bc /llvm/lib/CodeGen
parent74a7b9188a30777b712758362e8764589d40f3bc (diff)
downloadllvm-b4dfce2dba102eaef3fcb7f52fbb583bbae54a01.zip
llvm-b4dfce2dba102eaef3fcb7f52fbb583bbae54a01.tar.gz
llvm-b4dfce2dba102eaef3fcb7f52fbb583bbae54a01.tar.bz2
Two-address pass should use findCommutedOpIndices to determine what registers are commuted.
llvm-svn: 75317
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/TwoAddressInstructionPass.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
index 3c404046..b67f84b 100644
--- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
@@ -909,9 +909,16 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) {
}
// If it's profitable to commute the instruction, do so.
- if (TID.isCommutable() && mi->getNumOperands() >= 3) {
- unsigned regC = mi->getOperand(3-si).getReg();
- if (isProfitableToCommute(regB, regC, mi, mbbi, Dist))
+ unsigned SrcOp1, SrcOp2;
+ if (TID.isCommutable() && mi->getNumOperands() >= 3 &&
+ TII->findCommutedOpIndices(mi, SrcOp1, SrcOp2)) {
+ unsigned regC = 0;
+ if (si == SrcOp1)
+ regC = mi->getOperand(SrcOp2).getReg();
+ else if (si == SrcOp2)
+ regC = mi->getOperand(SrcOp1).getReg();
+
+ if (regC && isProfitableToCommute(regB, regC, mi, mbbi, Dist))
if (CommuteInstruction(mi, mbbi, regB, regC, Dist)) {
++NumAggrCommuted;
++NumCommuted;