From d9d86cb7386daf050ecb6c329109ac3b61587852 Mon Sep 17 00:00:00 2001 From: Nirav Dave Date: Wed, 16 May 2018 16:47:54 +0000 Subject: [PATCH] [DAG] Defer merge store cycle checking to just before merge. NFCI. llvm-svn: 332489 --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index aeea99894d6d..8a7b2f6f98b9 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -13473,14 +13473,6 @@ bool DAGCombiner::MergeConsecutiveStores(StoreSDNode *St) { continue; } - // Check that we can merge these candidates without causing a cycle - if (!checkMergeStoreCandidatesForDependencies(StoreNodes, - NumConsecutiveStores)) { - StoreNodes.erase(StoreNodes.begin(), - StoreNodes.begin() + NumConsecutiveStores); - continue; - } - // The node with the lowest store address. LLVMContext &Context = *DAG.getContext(); const DataLayout &DL = DAG.getDataLayout(); @@ -13576,6 +13568,12 @@ bool DAGCombiner::MergeConsecutiveStores(StoreSDNode *St) { continue; } + // Check that we can merge these candidates without causing a cycle. + if (!checkMergeStoreCandidatesForDependencies(StoreNodes, NumElem)) { + StoreNodes.erase(StoreNodes.begin(), StoreNodes.begin() + NumElem); + continue; + } + bool Merged = MergeStoresOfConstantsOrVecElts( StoreNodes, MemVT, NumElem, true, UseVector, LastIntegerTrunc); RV |= Merged; @@ -13634,6 +13632,14 @@ bool DAGCombiner::MergeConsecutiveStores(StoreSDNode *St) { continue; } + // Check that we can merge these candidates without causing a cycle. + if (!checkMergeStoreCandidatesForDependencies(StoreNodes, + NumStoresToMerge)) { + StoreNodes.erase(StoreNodes.begin(), + StoreNodes.begin() + NumStoresToMerge); + continue; + } + bool Merged = MergeStoresOfConstantsOrVecElts( StoreNodes, MemVT, NumStoresToMerge, false, true, false); if (!Merged) { @@ -13803,6 +13809,12 @@ bool DAGCombiner::MergeConsecutiveStores(StoreSDNode *St) { continue; } + // Check that we can merge these candidates without causing a cycle. + if (!checkMergeStoreCandidatesForDependencies(StoreNodes, NumElem)) { + StoreNodes.erase(StoreNodes.begin(), StoreNodes.begin() + NumElem); + continue; + } + // Find if it is better to use vectors or integers to load and store // to memory. EVT JointMemOpVT;