aboutsummaryrefslogtreecommitdiffstats
path: root/lib
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
commitebfc177b59c0bda0c2cb54f3f64dce7ee0fa4df2 (patch)
treecd5f68154bdd5b607daea70a68d177ba9fd54436 /lib
parent34c75093f085c7958fa3bd31f3c4a50942d83505 (diff)
downloadexternal_llvm-ebfc177b59c0bda0c2cb54f3f64dce7ee0fa4df2.zip
external_llvm-ebfc177b59c0bda0c2cb54f3f64dce7ee0fa4df2.tar.gz
external_llvm-ebfc177b59c0bda0c2cb54f3f64dce7ee0fa4df2.tar.bz2
Two-address pass should use findCommutedOpIndices to determine what registers are commuted.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75317 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/TwoAddressInstructionPass.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/CodeGen/TwoAddressInstructionPass.cpp b/lib/CodeGen/TwoAddressInstructionPass.cpp
index 3c40404..b67f84b 100644
--- a/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/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;