[llvm-commits] [llvm] r97688 - /llvm/trunk/lib/CodeGen/MachineCSE.cpp
Evan Cheng
evan.cheng at apple.com
Wed Mar 3 15:59:08 PST 2010
Author: evancheng
Date: Wed Mar 3 17:59:08 2010
New Revision: 97688
URL: http://llvm.org/viewvc/llvm-project?rev=97688&view=rev
Log:
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.
Modified:
llvm/trunk/lib/CodeGen/MachineCSE.cpp
Modified: llvm/trunk/lib/CodeGen/MachineCSE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineCSE.cpp?rev=97688&r1=97687&r2=97688&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineCSE.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineCSE.cpp Wed Mar 3 17:59:08 2010
@@ -128,8 +128,6 @@
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 @@
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);
More information about the llvm-commits
mailing list