Author: hans
Date: Thu Aug 10 18:53:40 2017
New Revision: 310678

URL: http://llvm.org/viewvc/llvm-project?rev=310678&view=rev
Log:
Merging r310604:
------------------------------------------------------------------------
r310604 | niravd | 2017-08-10 08:12:32 -0700 (Thu, 10 Aug 2017) | 13 lines

[X86] Keep dependencies when constructing loads in combineStore

Summary:
Preserve chain dependecies between old and new loads constructed to
prevent loads from reordering below later stores.

Fixes PR34088.

Reviewers: craig.topper, spatel, RKSimon, efriedma

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D36528
------------------------------------------------------------------------

Added:
    llvm/branches/release_50/test/CodeGen/X86/pr34088.ll
      - copied unchanged from r310604, llvm/trunk/test/CodeGen/X86/pr34088.ll
Modified:
    llvm/branches/release_50/   (props changed)
    llvm/branches/release_50/include/llvm/CodeGen/SelectionDAG.h
    llvm/branches/release_50/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
    llvm/branches/release_50/lib/Target/X86/X86ISelLowering.cpp

Propchange: llvm/branches/release_50/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Aug 10 18:53:40 2017
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,308483-308484,308503,308808,308813,308847,308891,308906,308950,308963,308978,308986,309113,309302,309321,309323,309325,309330,309343,309353,309355,309422,309481,309483,309495,309555,309561,309594,309614,309651,309744,309758,309849,309928,309930,310071,310190,310240-310242,310250,310253,310267,310481,310492,310510,310534,310552
+/llvm/trunk:155241,308483-308484,308503,308808,308813,308847,308891,308906,308950,308963,308978,308986,309113,309302,309321,309323,309325,309330,309343,309353,309355,309422,309481,309483,309495,309555,309561,309594,309614,309651,309744,309758,309849,309928,309930,310071,310190,310240-310242,310250,310253,310267,310481,310492,310510,310534,310552,310604

Modified: llvm/branches/release_50/include/llvm/CodeGen/SelectionDAG.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/branches/release_50/include/llvm/CodeGen/SelectionDAG.h?rev=310678&r1=310677&r2=310678&view=diff
==============================================================================
--- llvm/branches/release_50/include/llvm/CodeGen/SelectionDAG.h (original)
+++ llvm/branches/release_50/include/llvm/CodeGen/SelectionDAG.h Thu Aug 10 
18:53:40 2017
@@ -1220,8 +1220,9 @@ public:
   /// If an existing load has uses of its chain, create a token factor node 
with
   /// that chain and the new memory node's chain and update users of the old
   /// chain to the token factor. This ensures that the new memory node will 
have
-  /// the same relative memory dependency position as the old load.
-  void makeEquivalentMemoryOrdering(LoadSDNode *Old, SDValue New);
+  /// the same relative memory dependency position as the old load. Returns the
+  /// new merged load chain.
+  SDValue makeEquivalentMemoryOrdering(LoadSDNode *Old, SDValue New);
 
   /// Topological-sort the AllNodes list and a
   /// assign a unique node id for each node in the DAG based on their

Modified: llvm/branches/release_50/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/branches/release_50/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=310678&r1=310677&r2=310678&view=diff
==============================================================================
--- llvm/branches/release_50/lib/CodeGen/SelectionDAG/SelectionDAG.cpp 
(original)
+++ llvm/branches/release_50/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Aug 
10 18:53:40 2017
@@ -7262,22 +7262,23 @@ void SelectionDAG::TransferDbgValues(SDV
     AddDbgValue(I, ToNode, false);
 }
 
-void SelectionDAG::makeEquivalentMemoryOrdering(LoadSDNode *OldLoad,
-                                                SDValue NewMemOp) {
+SDValue SelectionDAG::makeEquivalentMemoryOrdering(LoadSDNode *OldLoad,
+                                                   SDValue NewMemOp) {
   assert(isa<MemSDNode>(NewMemOp.getNode()) && "Expected a memop node");
-  if (!OldLoad->hasAnyUseOfValue(1))
-    return;
-
   // The new memory operation must have the same position as the old load in
   // terms of memory dependency. Create a TokenFactor for the old load and new
   // memory operation and update uses of the old load's output chain to use 
that
   // TokenFactor.
   SDValue OldChain = SDValue(OldLoad, 1);
   SDValue NewChain = SDValue(NewMemOp.getNode(), 1);
+  if (!OldLoad->hasAnyUseOfValue(1))
+    return NewChain;
+
   SDValue TokenFactor =
       getNode(ISD::TokenFactor, SDLoc(OldLoad), MVT::Other, OldChain, 
NewChain);
   ReplaceAllUsesOfValueWith(OldChain, TokenFactor);
   UpdateNodeOperands(TokenFactor.getNode(), OldChain, NewChain);
+  return TokenFactor;
 }
 
 
//===----------------------------------------------------------------------===//

Modified: llvm/branches/release_50/lib/Target/X86/X86ISelLowering.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/branches/release_50/lib/Target/X86/X86ISelLowering.cpp?rev=310678&r1=310677&r2=310678&view=diff
==============================================================================
--- llvm/branches/release_50/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/branches/release_50/lib/Target/X86/X86ISelLowering.cpp Thu Aug 10 
18:53:40 2017
@@ -33386,7 +33386,8 @@ static SDValue combineStore(SDNode *N, S
       SDValue NewLd = DAG.getLoad(LdVT, LdDL, Ld->getChain(), Ld->getBasePtr(),
                                   Ld->getPointerInfo(), Ld->getAlignment(),
                                   Ld->getMemOperand()->getFlags());
-      SDValue NewChain = NewLd.getValue(1);
+      // Make sure new load is placed in same chain order.
+      SDValue NewChain = DAG.makeEquivalentMemoryOrdering(Ld, NewLd);
       if (TokenFactorIndex >= 0) {
         Ops.push_back(NewChain);
         NewChain = DAG.getNode(ISD::TokenFactor, LdDL, MVT::Other, Ops);
@@ -33407,11 +33408,12 @@ static SDValue combineStore(SDNode *N, S
                                Ld->getPointerInfo().getWithOffset(4),
                                MinAlign(Ld->getAlignment(), 4),
                                Ld->getMemOperand()->getFlags());
+    // Make sure new loads are placed in same chain order.
+    SDValue NewChain = DAG.makeEquivalentMemoryOrdering(Ld, LoLd);
+    NewChain = DAG.makeEquivalentMemoryOrdering(Ld, HiLd);
 
-    SDValue NewChain = LoLd.getValue(1);
     if (TokenFactorIndex >= 0) {
-      Ops.push_back(LoLd);
-      Ops.push_back(HiLd);
+      Ops.push_back(NewChain);
       NewChain = DAG.getNode(ISD::TokenFactor, LdDL, MVT::Other, Ops);
     }
 


_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to