[llvm] r309740 - [DAG] Factor out common expressions. NFC.
Nirav Dave via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 1 13:30:52 PDT 2017
Author: niravd
Date: Tue Aug 1 13:30:52 2017
New Revision: 309740
URL: http://llvm.org/viewvc/llvm-project?rev=309740&view=rev
Log:
[DAG] Factor out common expressions. NFC.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=309740&r1=309739&r2=309740&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Tue Aug 1 13:30:52 2017
@@ -12550,6 +12550,7 @@ void DAGCombiner::getStoreMergeCandidate
BaseIndexOffset BasePtr = BaseIndexOffset::match(St->getBasePtr(), DAG);
EVT MemVT = St->getMemoryVT();
+ SDValue Val = St->getValue();
// We must have a base and an offset.
if (!BasePtr.getBase().getNode())
return;
@@ -12558,17 +12559,15 @@ void DAGCombiner::getStoreMergeCandidate
if (BasePtr.getBase().isUndef())
return;
- 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());
+ bool IsConstantSrc = isa<ConstantSDNode>(Val) || isa<ConstantFPSDNode>(Val);
+ bool IsExtractVecSrc = (Val.getOpcode() == ISD::EXTRACT_VECTOR_ELT ||
+ Val.getOpcode() == ISD::EXTRACT_SUBVECTOR);
+ bool IsLoadSrc = isa<LoadSDNode>(Val);
BaseIndexOffset LBasePtr;
// Match on loadbaseptr if relevant.
EVT LoadVT;
if (IsLoadSrc) {
- auto *Ld = cast<LoadSDNode>(St->getValue());
+ auto *Ld = cast<LoadSDNode>(Val);
LBasePtr = BaseIndexOffset::match(Ld->getBasePtr(), DAG);
LoadVT = Ld->getMemoryVT();
// Load and store should be the same type.
@@ -12579,14 +12578,15 @@ void DAGCombiner::getStoreMergeCandidate
int64_t &Offset) -> bool {
if (Other->isVolatile() || Other->isIndexed())
return false;
+ SDValue Val = Other->getValue();
// We can merge constant floats to equivalent integers
if (Other->getMemoryVT() != MemVT)
if (!(MemVT.isInteger() && MemVT.bitsEq(Other->getMemoryVT()) &&
- isa<ConstantFPSDNode>(Other->getValue())))
+ isa<ConstantFPSDNode>(Val)))
return false;
if (IsLoadSrc) {
// The Load's Base Ptr must also match
- if (LoadSDNode *OtherLd = dyn_cast<LoadSDNode>(Other->getValue())) {
+ if (LoadSDNode *OtherLd = dyn_cast<LoadSDNode>(Val)) {
auto LPtr = BaseIndexOffset::match(OtherLd->getBasePtr(), DAG);
if (LoadVT != OtherLd->getMemoryVT())
return false;
@@ -12595,14 +12595,15 @@ void DAGCombiner::getStoreMergeCandidate
} else
return false;
}
- if (IsConstantSrc)
- if (!(isa<ConstantSDNode>(Other->getValue()) ||
- isa<ConstantFPSDNode>(Other->getValue())))
+ if (IsConstantSrc) {
+ if (!(isa<ConstantSDNode>(Val) || isa<ConstantFPSDNode>(Val)))
return false;
- if (IsExtractVecSrc)
- if (!(Other->getValue().getOpcode() == ISD::EXTRACT_VECTOR_ELT ||
- Other->getValue().getOpcode() == ISD::EXTRACT_SUBVECTOR))
+ }
+ if (IsExtractVecSrc) {
+ if (!(Val.getOpcode() == ISD::EXTRACT_VECTOR_ELT ||
+ Val.getOpcode() == ISD::EXTRACT_SUBVECTOR))
return false;
+ }
Ptr = BaseIndexOffset::match(Other->getBasePtr(), DAG);
return (BasePtr.equalBaseIndex(Ptr, DAG, Offset));
};
@@ -12876,14 +12877,14 @@ bool DAGCombiner::MergeConsecutiveStores
unsigned NumStoresToMerge = 1;
for (unsigned i = 0; i < NumConsecutiveStores; ++i) {
StoreSDNode *St = cast<StoreSDNode>(StoreNodes[i].MemNode);
- unsigned StoreValOpcode = St->getValue().getOpcode();
+ SDValue StVal = St->getValue();
// This restriction could be loosened.
// Bail out if any stored values are not elements extracted from a
// vector. It should be possible to handle mixed sources, but load
// sources need more careful handling (see the block of code below that
// handles consecutive loads).
- if (StoreValOpcode != ISD::EXTRACT_VECTOR_ELT &&
- StoreValOpcode != ISD::EXTRACT_SUBVECTOR)
+ if (StVal.getOpcode() != ISD::EXTRACT_VECTOR_ELT &&
+ StVal.getOpcode() != ISD::EXTRACT_SUBVECTOR)
return RV;
// Find a legal type for the vector store.
@@ -12925,7 +12926,8 @@ bool DAGCombiner::MergeConsecutiveStores
BaseIndexOffset LdBasePtr;
for (unsigned i = 0; i < NumConsecutiveStores; ++i) {
StoreSDNode *St = cast<StoreSDNode>(StoreNodes[i].MemNode);
- LoadSDNode *Ld = dyn_cast<LoadSDNode>(St->getValue());
+ SDValue Val = St->getValue();
+ LoadSDNode *Ld = dyn_cast<LoadSDNode>(Val);
if (!Ld)
break;
More information about the llvm-commits
mailing list