<div dir="ltr">Someone commented on Phab but not here: this appears to have broken all the PPC bots. Please revert ASAP to get them back.</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Dec 19, 2017 at 12:11 PM Nirav Dave via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: niravd<br>
Date: Tue Dec 19 09:10:56 2017<br>
New Revision: 321089<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=321089&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=321089&view=rev</a><br>
Log:<br>
[DAG] Elide overlapping store<br>
<br>
Summary:<br>
Extend overlapping store elision to handle overwrites of stores by<br>
larger stores.<br>
<br>
Nontemporal tests have been modified to add memory dependencies to<br>
prevent store elision.<br>
<br>
Reviewers: craig.topper, rnk, t.p.northover<br>
<br>
Subscribers: javed.absar, hiraditya, llvm-commits<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D40969" rel="noreferrer" target="_blank">https://reviews.llvm.org/D40969</a><br>
<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp<br>
    llvm/trunk/test/CodeGen/AArch64/ldst-paired-aliasing.ll<br>
<br>
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=321089&r1=321088&r2=321089&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=321089&r1=321088&r2=321089&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Tue Dec 19 09:10:56 2017<br>
@@ -13784,30 +13784,30 @@ SDValue DAGCombiner::visitSTORE(SDNode *<br>
     }<br>
   }<br>
<br>
-  if (StoreSDNode *ST1 = dyn_cast<StoreSDNode>(Chain)) {<br>
-    if (ST->isUnindexed() && !ST->isVolatile() && ST1->isUnindexed() &&<br>
-        !ST1->isVolatile() && ST1->getBasePtr() == Ptr &&<br>
-        ST->getMemoryVT() == ST1->getMemoryVT()) {<br>
-      // If this is a store followed by a store with the same value to the same<br>
-      // location, then the store is dead/noop.<br>
-      if (ST1->getValue() == Value) {<br>
-        // The store is dead, remove it.<br>
-        return Chain;<br>
-      }<br>
+  // Deal with elidable overlapping chained stores.<br>
+  if (StoreSDNode *ST1 = dyn_cast<StoreSDNode>(Chain))<br>
+    if (OptLevel != CodeGenOpt::None && ST1->isUnindexed() &&<br>
+        !ST1->isVolatile() && ST1->hasOneUse() &&<br>
+        !ST1->getBasePtr().isUndef() && !ST->isVolatile()) {<br>
+      BaseIndexOffset STBasePtr = BaseIndexOffset::match(ST->getBasePtr(), DAG);<br>
+      BaseIndexOffset ST1BasePtr =<br>
+          BaseIndexOffset::match(ST1->getBasePtr(), DAG);<br>
+      unsigned STBytes = ST->getMemoryVT().getStoreSize();<br>
+      unsigned ST1Bytes = ST1->getMemoryVT().getStoreSize();<br>
+      int64_t PtrDiff;<br>
+      // If this is a store who's preceeding store to a subset of the same<br>
+      // memory and no one other node is chained to that store we can<br>
+      // effectively drop the store. Do not remove stores to undef as they may<br>
+      // be used as data sinks.<br>
<br>
-      // If this is a store who's preceeding store to the same location<br>
-      // and no one other node is chained to that store we can effectively<br>
-      // drop the store. Do not remove stores to undef as they may be used as<br>
-      // data sinks.<br>
-      if (OptLevel != CodeGenOpt::None && ST1->hasOneUse() &&<br>
-          !ST1->getBasePtr().isUndef()) {<br>
-        // ST1 is fully overwritten and can be elided. Combine with it's chain<br>
-        // value.<br>
+      if (((ST->getBasePtr() == ST1->getBasePtr()) &&<br>
+           (ST->getValue() == ST1->getValue())) ||<br>
+          (STBasePtr.equalBaseIndex(ST1BasePtr, DAG, PtrDiff) &&<br>
+           (0 <= PtrDiff) && (PtrDiff + ST1Bytes <= STBytes))) {<br>
         CombineTo(ST1, ST1->getChain());<br>
-        return SDValue();<br>
+        return SDValue(N, 0);<br>
       }<br>
     }<br>
-  }<br>
<br>
   // If this is an FP_ROUND or TRUNC followed by a store, fold this into a<br>
   // truncating store.  We can do this even if this is already a truncstore.<br>
<br>
Modified: llvm/trunk/test/CodeGen/AArch64/ldst-paired-aliasing.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/ldst-paired-aliasing.ll?rev=321089&r1=321088&r2=321089&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/ldst-paired-aliasing.ll?rev=321089&r1=321088&r2=321089&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/CodeGen/AArch64/ldst-paired-aliasing.ll (original)<br>
+++ llvm/trunk/test/CodeGen/AArch64/ldst-paired-aliasing.ll Tue Dec 19 09:10:56 2017<br>
@@ -10,11 +10,10 @@ declare void @llvm.memset.p0i8.i64(i8* n<br>
 define i32 @main() local_unnamed_addr #1 {<br>
 ; Make sure the stores happen in the correct order (the exact instructions could change).<br>
 ; CHECK-LABEL: main:<br>
-; CHECK: stp xzr, xzr, [sp, #72]<br>
+; CHECK: str xzr, [sp, #80]<br>
 ; CHECK: str w9, [sp, #80]<br>
-; CHECK: str q0, [sp, #48]<br>
+; CHECK: stp q0, q0, [sp, #48]<br>
 ; CHECK: ldr w8, [sp, #48]<br>
-; CHECK: str q0, [sp, #64]<br>
<br>
 for.body.lr.ph.i.i.i.i.i.i63:<br>
   %b1 = alloca [10 x i32], align 16<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>