[llvm-commits] [llvm] r40722 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/ScheduleDAG.cpp lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Evan Cheng
evan.cheng at apple.com
Wed Aug 1 22:29:38 PDT 2007
Author: evancheng
Date: Thu Aug 2 00:29:38 2007
New Revision: 40722
URL: http://llvm.org/viewvc/llvm-project?rev=40722&view=rev
Log:
Do not emit copies for physical register output if it's not used.
Modified:
llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=40722&r1=40721&r2=40722&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Thu Aug 2 00:29:38 2007
@@ -858,6 +858,10 @@
/// operation.
bool hasNUsesOfValue(unsigned NUses, unsigned Value) const;
+ /// hasAnyUseOfValue - Return true if there are any use of the indicated
+ /// value. This method ignores uses of other values defined by this operation.
+ bool hasAnyUseOfValue(unsigned Value) const;
+
/// isOnlyUse - Return true if this node is the only use of N.
///
bool isOnlyUse(SDNode *N) const;
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp?rev=40722&r1=40721&r2=40722&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp Thu Aug 2 00:29:38 2007
@@ -676,7 +676,8 @@
if (HasPhysRegOuts) {
for (unsigned i = II.numDefs; i < NumResults; ++i) {
unsigned Reg = II.ImplicitDefs[i - II.numDefs];
- EmitCopyFromReg(Node, i, Reg, VRBaseMap);
+ if (Node->hasAnyUseOfValue(i))
+ EmitCopyFromReg(Node, i, Reg, VRBaseMap);
}
}
} else {
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=40722&r1=40721&r2=40722&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Aug 2 00:29:38 2007
@@ -3242,7 +3242,7 @@
// If there is only one value, this is easy.
if (getNumValues() == 1)
return use_size() == NUses;
- if (Uses.size() < NUses) return false;
+ if (use_size() < NUses) return false;
SDOperand TheValue(const_cast<SDNode *>(this), Value);
@@ -3265,6 +3265,31 @@
}
+/// hasAnyUseOfValue - Return true if there are any use of the indicated
+/// value. This method ignores uses of other values defined by this operation.
+bool SDNode::hasAnyUseOfValue(unsigned Value) const {
+ assert(Value < getNumValues() && "Bad value!");
+
+ if (use_size() == 0) return false;
+
+ SDOperand TheValue(const_cast<SDNode *>(this), Value);
+
+ SmallPtrSet<SDNode*, 32> UsersHandled;
+
+ for (SDNode::use_iterator UI = Uses.begin(), E = Uses.end(); UI != E; ++UI) {
+ SDNode *User = *UI;
+ if (User->getNumOperands() == 1 ||
+ UsersHandled.insert(User)) // First time we've seen this?
+ for (unsigned i = 0, e = User->getNumOperands(); i != e; ++i)
+ if (User->getOperand(i) == TheValue) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
/// isOnlyUse - Return true if this node is the only use of N.
///
bool SDNode::isOnlyUse(SDNode *N) const {
More information about the llvm-commits
mailing list