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
This commit is contained in:
Evan Cheng 2010-03-03 23:59:08 +00:00
parent 2d23779e7d
commit 2922641a7e
1 changed files with 5 additions and 2 deletions

View File

@ -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);