aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2007-05-01 00:38:21 +0000
committerEvan Cheng <evan.cheng@apple.com>2007-05-01 00:38:21 +0000
commit45a7ca9b23e7e3447465cdf97788d137aa98cb47 (patch)
tree02270f456f5e4166c59501a1527d7555f8aa3629
parent5443779d5a58426073cf0525bb78f732059311b9 (diff)
* Only turn a load to UNDEF if all of its outputs have no uses (indexed loads
produce two results.) * Do not touch volatile loads. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36604 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/SelectionDAG/DAGCombiner.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 2cbd10dc54..4b57ecfcbc 100644
--- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -3326,11 +3326,26 @@ SDOperand DAGCombiner::visitLOAD(SDNode *N) {
LoadSDNode *LD = cast<LoadSDNode>(N);
SDOperand Chain = LD->getChain();
SDOperand Ptr = LD->getBasePtr();
-
- // If there are no uses of the loaded value, change uses of the chain value
- // into uses of the chain input (i.e. delete the dead load).
- if (N->hasNUsesOfValue(0, 0))
- return CombineTo(N, DAG.getNode(ISD::UNDEF, N->getValueType(0)), Chain);
+
+ // If load is not volatile and there are no uses of the loaded value (and
+ // the updated indexed value in case of indexed loads), change uses of the
+ // chain value into uses of the chain input (i.e. delete the dead load).
+ if (!LD->isVolatile()) {
+ bool HasUses = false;
+ SmallVector<MVT::ValueType, 2> VTs;
+ for (unsigned i = 0, e = N->getNumValues(); i != e; ++i) {
+ if (!N->hasNUsesOfValue(0, i)) {
+ HasUses = true;
+ break;
+ }
+ VTs.push_back(N->getValueType(i));
+ }
+ if (!HasUses) {
+ SmallVector<SDOperand, 1> Ops;
+ return CombineTo(N, DAG.getNode(ISD::UNDEF, &VTs[0], VTs.size(), 0, 0),
+ Chain);
+ }
+ }
// If this load is directly stored, replace the load value with the stored
// value.