]> granicus.if.org Git - llvm/commitdiff
[DAG] Add Target Store Merge pass ordering function
authorNirav Dave <niravd@google.com>
Thu, 22 Jun 2017 15:07:49 +0000 (15:07 +0000)
committerNirav Dave <niravd@google.com>
Thu, 22 Jun 2017 15:07:49 +0000 (15:07 +0000)
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

include/llvm/Target/TargetLowering.h
lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index cd83df533404f2a4e09d4b48018fd93d38cb3eb1..0b46b05308e382af320f61fee1e45335bae2354e 100644 (file)
@@ -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;
index 14a722a59e8a0829b0273d82f799c849da905932..d02dcb6f4439b3ee7cae28b3a15f7c9d6e623f8c 100644 (file)
@@ -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