From: Nirav Dave Date: Thu, 22 Jun 2017 15:07:49 +0000 (+0000) Subject: [DAG] Add Target Store Merge pass ordering function X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9bd0f56ab3e4de18c1caea0cabfc2cb541be00ef;p=llvm [DAG] Add Target Store Merge pass ordering function Allow targets to specify if they should merge stores before or after legalization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306006 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index cd83df53340..0b46b05308e 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -410,6 +410,10 @@ public: return false; } + /// Should we merge stores after Legalization (generally + /// better quality) or before (simpler) + virtual bool mergeStoresAfterLegalization() const { return false; } + /// Returns if it's reasonable to merge stores to MemVT size. virtual bool canMergeStoresTo(unsigned AddressSpace, EVT MemVT) const { return true; diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 14a722a59e8..d02dcb6f443 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -13209,7 +13209,8 @@ SDValue DAGCombiner::visitSTORE(SDNode *N) { // Only perform this optimization before the types are legal, because we // don't want to perform this optimization on every DAGCombine invocation. - if (!LegalTypes) { + if ((TLI.mergeStoresAfterLegalization()) ? Level == AfterLegalizeDAG + : !LegalTypes) { for (;;) { // There can be multiple store sequences on the same chain. // Keep trying to merge store sequences until we are unable to do so