diff options
author | Nirav Dave <niravd@google.com> | 2017-06-07 18:51:56 +0000 |
---|---|---|
committer | Nirav Dave <niravd@google.com> | 2017-06-07 18:51:56 +0000 |
commit | 772ea3ae1a8b44d0ce1930b463a93e67bea4c0c5 (patch) | |
tree | ace3c7b9d67c27482cf6709b6ba35f99824d450e /llvm/lib/CodeGen | |
parent | 4f49bee764da46d7d30408d8b3ff63e1127270dd (diff) | |
download | bcm5719-llvm-772ea3ae1a8b44d0ce1930b463a93e67bea4c0c5.tar.gz bcm5719-llvm-772ea3ae1a8b44d0ce1930b463a93e67bea4c0c5.zip |
[DAG] Improve Store Merge candidate pruning. NFC.
When considering merging stores values are the results of loads only
consider stores whose values come from loads from the same base.
This fixes much of the longer compile times in PR33330.
llvm-svn: 304934
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 0cf2ab2a62e..a0967f57400 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -12488,12 +12488,18 @@ void DAGCombiner::getStoreMergeCandidates( if (BasePtr.Base.isUndef()) return; - bool IsLoadSrc = isa<LoadSDNode>(St->getValue()); bool IsConstantSrc = isa<ConstantSDNode>(St->getValue()) || isa<ConstantFPSDNode>(St->getValue()); bool IsExtractVecSrc = (St->getValue().getOpcode() == ISD::EXTRACT_VECTOR_ELT || St->getValue().getOpcode() == ISD::EXTRACT_SUBVECTOR); + bool IsLoadSrc = isa<LoadSDNode>(St->getValue()); + BaseIndexOffset LBasePtr; + // Match on loadbaseptr if relevant. + if (IsLoadSrc) + LBasePtr = BaseIndexOffset::match( + cast<LoadSDNode>(St->getValue())->getBasePtr(), DAG); + auto CandidateMatch = [&](StoreSDNode *Other, BaseIndexOffset &Ptr) -> bool { if (Other->isVolatile() || Other->isIndexed()) return false; @@ -12502,9 +12508,15 @@ void DAGCombiner::getStoreMergeCandidates( if (!(MemVT.isInteger() && MemVT.bitsEq(Other->getMemoryVT()) && isa<ConstantFPSDNode>(Other->getValue()))) return false; - if (IsLoadSrc) - if (!isa<LoadSDNode>(Other->getValue())) + if (IsLoadSrc) { + // The Load's Base Ptr must also match + if (LoadSDNode *OtherLd = dyn_cast<LoadSDNode>(Other->getValue())) { + auto LPtr = BaseIndexOffset::match(OtherLd->getBasePtr(), DAG); + if (!(LBasePtr.equalBaseIndex(LPtr))) + return false; + } else return false; + } if (IsConstantSrc) if (!(isa<ConstantSDNode>(Other->getValue()) || isa<ConstantFPSDNode>(Other->getValue()))) |