From dcc5afaad9e0fc807bb6741be783a99fa6e2c149 Mon Sep 17 00:00:00 2001 From: Nirav Dave Date: Tue, 1 Aug 2017 20:30:52 +0000 Subject: [DAG] Factor out common expressions. NFC. llvm-svn: 309740 --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 40 ++++++++++++++------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'llvm/lib/CodeGen/SelectionDAG') diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index d5a61a7f171..54cddf77b4c 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -12550,6 +12550,7 @@ void DAGCombiner::getStoreMergeCandidates( 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::getStoreMergeCandidates( if (BasePtr.getBase().isUndef()) return; - bool IsConstantSrc = isa(St->getValue()) || - isa(St->getValue()); - bool IsExtractVecSrc = - (St->getValue().getOpcode() == ISD::EXTRACT_VECTOR_ELT || - St->getValue().getOpcode() == ISD::EXTRACT_SUBVECTOR); - bool IsLoadSrc = isa(St->getValue()); + bool IsConstantSrc = isa(Val) || isa(Val); + bool IsExtractVecSrc = (Val.getOpcode() == ISD::EXTRACT_VECTOR_ELT || + Val.getOpcode() == ISD::EXTRACT_SUBVECTOR); + bool IsLoadSrc = isa(Val); BaseIndexOffset LBasePtr; // Match on loadbaseptr if relevant. EVT LoadVT; if (IsLoadSrc) { - auto *Ld = cast(St->getValue()); + auto *Ld = cast(Val); LBasePtr = BaseIndexOffset::match(Ld->getBasePtr(), DAG); LoadVT = Ld->getMemoryVT(); // Load and store should be the same type. @@ -12579,14 +12578,15 @@ void DAGCombiner::getStoreMergeCandidates( 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(Other->getValue()))) + isa(Val))) return false; if (IsLoadSrc) { // The Load's Base Ptr must also match - if (LoadSDNode *OtherLd = dyn_cast(Other->getValue())) { + if (LoadSDNode *OtherLd = dyn_cast(Val)) { auto LPtr = BaseIndexOffset::match(OtherLd->getBasePtr(), DAG); if (LoadVT != OtherLd->getMemoryVT()) return false; @@ -12595,14 +12595,15 @@ void DAGCombiner::getStoreMergeCandidates( } else return false; } - if (IsConstantSrc) - if (!(isa(Other->getValue()) || - isa(Other->getValue()))) + if (IsConstantSrc) { + if (!(isa(Val) || isa(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(StoreSDNode *St) { unsigned NumStoresToMerge = 1; for (unsigned i = 0; i < NumConsecutiveStores; ++i) { StoreSDNode *St = cast(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(StoreSDNode *St) { BaseIndexOffset LdBasePtr; for (unsigned i = 0; i < NumConsecutiveStores; ++i) { StoreSDNode *St = cast(StoreNodes[i].MemNode); - LoadSDNode *Ld = dyn_cast(St->getValue()); + SDValue Val = St->getValue(); + LoadSDNode *Ld = dyn_cast(Val); if (!Ld) break; -- cgit v1.2.3