summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineCSE.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2010-03-03 23:59:08 +0000
committerEvan Cheng <evan.cheng@apple.com>2010-03-03 23:59:08 +0000
commit2922641a7e014019c4041d9e099a76a1827633a0 (patch)
tree2faf8d88044ee48e358458d905ccc6ede0b92333 /llvm/lib/CodeGen/MachineCSE.cpp
parent2d23779e7deb9ca43c748208ef010a090b62bd01 (diff)
downloadbcm5719-llvm-2922641a7e014019c4041d9e099a76a1827633a0.tar.gz
bcm5719-llvm-2922641a7e014019c4041d9e099a76a1827633a0.zip
Fix a logic error. An instruction that has a live physical register def cannot be CSE'ed, but it *can* be used to replace a common subexpression.
llvm-svn: 97688
Diffstat (limited to 'llvm/lib/CodeGen/MachineCSE.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineCSE.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/MachineCSE.cpp b/llvm/lib/CodeGen/MachineCSE.cpp
index ea11bfbdb89..d542cc9969a 100644
--- a/llvm/lib/CodeGen/MachineCSE.cpp
+++ b/llvm/lib/CodeGen/MachineCSE.cpp
@@ -128,8 +128,6 @@ bool MachineCSE::ProcessBlock(MachineDomTreeNode *Node) {
if (TII->isMoveInstr(*MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx) ||
MI->isExtractSubreg() || MI->isInsertSubreg() || MI->isSubregToReg())
continue;
- if (hasLivePhysRegDefUse(MI))
- continue;
bool FoundCSE = VNT.count(MI);
if (!FoundCSE) {
@@ -138,6 +136,11 @@ bool MachineCSE::ProcessBlock(MachineDomTreeNode *Node) {
FoundCSE = VNT.count(MI);
}
+ // If the instruction defines a physical register and the value *may* be
+ // used, then it's not safe to replace it with a common subexpression.
+ if (FoundCSE && hasLivePhysRegDefUse(MI))
+ FoundCSE = false;
+
if (!FoundCSE) {
VNT.insert(MI, CurrVN++);
Exps.push_back(MI);
OpenPOWER on IntegriCloud