forked from OSchip/llvm-project
[DAGCombine] Move load checks on store of loads into candidate
search. NFCI. Migrate single-use and non-volatility, non-indexed requirements on stores of immediate store values to candidate collection pass from later stage. llvm-svn: 332392
This commit is contained in:
parent
28d4ddab86
commit
a87de7d846
|
@ -13258,6 +13258,12 @@ void DAGCombiner::getStoreMergeCandidates(
|
||||||
// Load and store should be the same type.
|
// Load and store should be the same type.
|
||||||
if (MemVT != LoadVT)
|
if (MemVT != LoadVT)
|
||||||
return;
|
return;
|
||||||
|
// Loads must only have one use.
|
||||||
|
if (!Ld->hasNUsesOfValue(1, 0))
|
||||||
|
return;
|
||||||
|
// The memory operands must not be volatile.
|
||||||
|
if (Ld->isVolatile() || Ld->isIndexed())
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
auto CandidateMatch = [&](StoreSDNode *Other, BaseIndexOffset &Ptr,
|
auto CandidateMatch = [&](StoreSDNode *Other, BaseIndexOffset &Ptr,
|
||||||
int64_t &Offset) -> bool {
|
int64_t &Offset) -> bool {
|
||||||
|
@ -13275,6 +13281,12 @@ void DAGCombiner::getStoreMergeCandidates(
|
||||||
auto LPtr = BaseIndexOffset::match(OtherLd, DAG);
|
auto LPtr = BaseIndexOffset::match(OtherLd, DAG);
|
||||||
if (LoadVT != OtherLd->getMemoryVT())
|
if (LoadVT != OtherLd->getMemoryVT())
|
||||||
return false;
|
return false;
|
||||||
|
// Loads must only have one use.
|
||||||
|
if (!OtherLd->hasNUsesOfValue(1, 0))
|
||||||
|
return false;
|
||||||
|
// The memory operands must not be volatile.
|
||||||
|
if (OtherLd->isVolatile() || OtherLd->isIndexed())
|
||||||
|
return false;
|
||||||
if (!(LBasePtr.equalBaseIndex(LPtr, DAG)))
|
if (!(LBasePtr.equalBaseIndex(LPtr, DAG)))
|
||||||
return false;
|
return false;
|
||||||
} else
|
} else
|
||||||
|
@ -13649,21 +13661,7 @@ bool DAGCombiner::MergeConsecutiveStores(StoreSDNode *St) {
|
||||||
for (unsigned i = 0; i < NumConsecutiveStores; ++i) {
|
for (unsigned i = 0; i < NumConsecutiveStores; ++i) {
|
||||||
StoreSDNode *St = cast<StoreSDNode>(StoreNodes[i].MemNode);
|
StoreSDNode *St = cast<StoreSDNode>(StoreNodes[i].MemNode);
|
||||||
SDValue Val = peekThroughBitcast(St->getValue());
|
SDValue Val = peekThroughBitcast(St->getValue());
|
||||||
LoadSDNode *Ld = dyn_cast<LoadSDNode>(Val);
|
LoadSDNode *Ld = cast<LoadSDNode>(Val);
|
||||||
if (!Ld)
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Loads must only have one use.
|
|
||||||
if (!Ld->hasNUsesOfValue(1, 0))
|
|
||||||
break;
|
|
||||||
|
|
||||||
// The memory operands must not be volatile.
|
|
||||||
if (Ld->isVolatile() || Ld->isIndexed())
|
|
||||||
break;
|
|
||||||
|
|
||||||
// The stored memory type must be the same.
|
|
||||||
if (Ld->getMemoryVT() != MemVT)
|
|
||||||
break;
|
|
||||||
|
|
||||||
BaseIndexOffset LdPtr = BaseIndexOffset::match(Ld, DAG);
|
BaseIndexOffset LdPtr = BaseIndexOffset::match(Ld, DAG);
|
||||||
// If this is not the first ptr that we check.
|
// If this is not the first ptr that we check.
|
||||||
|
|
Loading…
Reference in New Issue