aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-10-10 22:31:19 +0000
committerChris Lattner <sabre@nondot.org>2005-10-10 22:31:19 +0000
commit87514ca04cb069310d29fd77e0501601c1e22c11 (patch)
tree2422f9b3342c6bf1b4a874401b37f768cedee266 /lib
parent01a220213852223f2503f05c8bbb8b72e3c71290 (diff)
downloadexternal_llvm-87514ca04cb069310d29fd77e0501601c1e22c11.zip
external_llvm-87514ca04cb069310d29fd77e0501601c1e22c11.tar.gz
external_llvm-87514ca04cb069310d29fd77e0501601c1e22c11.tar.bz2
Implement trivial DSE. If two stores are neighbors and store to the same
location, replace them with a new store of the last value. This occurs in the same neighborhood in 197.parser, speeding it up about 1.5% git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23691 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/SelectionDAG/DAGCombiner.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 7fde0ad..b58b8ca 100644
--- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -77,6 +77,7 @@ namespace {
}
SDOperand CombineTo(SDNode *N, const std::vector<SDOperand> &To) {
+ ++NodesCombined;
DEBUG(std::cerr << "\nReplacing "; N->dump();
std::cerr << "\nWith: "; To[0].Val->dump();
std::cerr << " and " << To.size()-1 << " other values\n");
@@ -99,6 +100,12 @@ namespace {
DAG.DeleteNode(N);
return SDOperand(N, 0);
}
+
+ SDOperand CombineTo(SDNode *N, SDOperand Res) {
+ std::vector<SDOperand> To;
+ To.push_back(Res);
+ return CombineTo(N, To);
+ }
SDOperand CombineTo(SDNode *N, SDOperand Res0, SDOperand Res1) {
std::vector<SDOperand> To;
@@ -165,6 +172,7 @@ namespace {
SDOperand visitBRTWOWAY_CC(SDNode *N);
SDOperand visitLOAD(SDNode *N);
+ SDOperand visitSTORE(SDNode *N);
SDOperand SimplifySelect(SDOperand N0, SDOperand N1, SDOperand N2);
SDOperand SimplifySelectCC(SDOperand N0, SDOperand N1, SDOperand N2,
@@ -439,6 +447,7 @@ SDOperand DAGCombiner::visit(SDNode *N) {
case ISD::BR_CC: return visitBR_CC(N);
case ISD::BRTWOWAY_CC: return visitBRTWOWAY_CC(N);
case ISD::LOAD: return visitLOAD(N);
+ case ISD::STORE: return visitSTORE(N);
}
return SDOperand();
}
@@ -1567,6 +1576,26 @@ SDOperand DAGCombiner::visitLOAD(SDNode *N) {
return SDOperand();
}
+SDOperand DAGCombiner::visitSTORE(SDNode *N) {
+ SDOperand Chain = N->getOperand(0);
+ SDOperand Value = N->getOperand(1);
+ SDOperand Ptr = N->getOperand(2);
+ SDOperand SrcValue = N->getOperand(3);
+
+ // If this is a store that kills a previous store, remove the previous store.
+ if (Chain.getOpcode() == ISD::STORE && Chain.getOperand(2) == Ptr) {
+ // Create a new store of Value that replaces both stores.
+ SDNode *PrevStore = Chain.Val;
+ SDOperand NewStore = DAG.getNode(ISD::STORE, MVT::Other,
+ PrevStore->getOperand(0), Value, Ptr,
+ SrcValue);
+ CombineTo(PrevStore, NewStore); // Nuke the previous store.
+ return NewStore; // Replace this store with NewStore.
+ }
+
+ return SDOperand();
+}
+
SDOperand DAGCombiner::SimplifySelect(SDOperand N0, SDOperand N1, SDOperand N2){
assert(N0.getOpcode() ==ISD::SETCC && "First argument must be a SetCC node!");