diff options
author | Evan Cheng <evan.cheng@apple.com> | 2010-03-03 23:59:08 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2010-03-03 23:59:08 +0000 |
commit | 67bda7215b4bc1b3cc9dd80ef5785ac6dd26fb8c (patch) | |
tree | 1074fe43ff167092570a881ebd662b997988f500 /lib/CodeGen/MachineCSE.cpp | |
parent | a92dced4a186c03f06a1e9156ca00d997ef0a972 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97688 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineCSE.cpp')
-rw-r--r-- | lib/CodeGen/MachineCSE.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/CodeGen/MachineCSE.cpp b/lib/CodeGen/MachineCSE.cpp index ea11bfbdb8..d542cc9969 100644 --- a/lib/CodeGen/MachineCSE.cpp +++ b/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); |