[llvm] r322085 - [DAG] Elide overlapping stores

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 15 02:59:26 PST 2018


I had to revert this again in r322474 (sorry). It's still hitting the
same PPC issue it did last time.

On Tue, Jan 9, 2018 at 4:23 PM, Nirav Dave via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: niravd
> Date: Tue Jan  9 07:23:12 2018
> New Revision: 322085
>
> URL: http://llvm.org/viewvc/llvm-project?rev=322085&view=rev
> Log:
> [DAG] Elide overlapping stores
>
> Relanding after fixing handling of pre-indexed memory operations in
> BaseIndexOffset analysis (r322003).
>
> Extend overlapping store elision to handle overwrites of stores by
> larger stores.
>
> Reviewers: craig.topper, rnk, t.p.northover
>
> Subscribers: javed.absar, hiraditya, llvm-commits
>
> Differential Revision: https://reviews.llvm.org/D40969
>
> Modified:
>     llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
>     llvm/trunk/test/CodeGen/AArch64/ldst-paired-aliasing.ll
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=322085&r1=322084&r2=322085&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Tue Jan  9 07:23:12 2018
> @@ -13798,30 +13798,29 @@ SDValue DAGCombiner::visitSTORE(SDNode *
>      }
>    }
>
> -  if (StoreSDNode *ST1 = dyn_cast<StoreSDNode>(Chain)) {
> -    if (ST->isUnindexed() && !ST->isVolatile() && ST1->isUnindexed() &&
> -        !ST1->isVolatile() && ST1->getBasePtr() == Ptr &&
> -        ST->getMemoryVT() == ST1->getMemoryVT()) {
> -      // If this is a store followed by a store with the same value to the same
> -      // location, then the store is dead/noop.
> -      if (ST1->getValue() == Value) {
> -        // The store is dead, remove it.
> -        return Chain;
> -      }
> +  // Deal with elidable overlapping chained stores.
> +  if (StoreSDNode *ST1 = dyn_cast<StoreSDNode>(Chain))
> +    if (OptLevel != CodeGenOpt::None && ST->isUnindexed() &&
> +        ST1->isUnindexed() && !ST1->isVolatile() && ST1->hasOneUse() &&
> +        !ST1->getBasePtr().isUndef() && !ST->isVolatile()) {
> +      BaseIndexOffset STBasePtr = BaseIndexOffset::match(ST, DAG);
> +      BaseIndexOffset ST1BasePtr = BaseIndexOffset::match(ST1, DAG);
> +      unsigned STBytes = ST->getMemoryVT().getStoreSize();
> +      unsigned ST1Bytes = ST1->getMemoryVT().getStoreSize();
> +      int64_t PtrDiff;
> +      // If this is a store who's preceeding store to a subset of the same
> +      // memory and no one other node is chained to that store we can
> +      // effectively drop the store. Do not remove stores to undef as they may
> +      // be used as data sinks.
>
> -      // If this is a store who's preceeding store to the same location
> -      // and no one other node is chained to that store we can effectively
> -      // drop the store. Do not remove stores to undef as they may be used as
> -      // data sinks.
> -      if (OptLevel != CodeGenOpt::None && ST1->hasOneUse() &&
> -          !ST1->getBasePtr().isUndef()) {
> -        // ST1 is fully overwritten and can be elided. Combine with it's chain
> -        // value.
> +      if (((ST->getBasePtr() == ST1->getBasePtr()) &&
> +           (ST->getValue() == ST1->getValue())) ||
> +          (STBasePtr.equalBaseIndex(ST1BasePtr, DAG, PtrDiff) &&
> +           (0 <= PtrDiff) && (PtrDiff + ST1Bytes <= STBytes))) {
>          CombineTo(ST1, ST1->getChain());
> -        return SDValue();
> +        return SDValue(N, 0);
>        }
>      }
> -  }
>
>    // If this is an FP_ROUND or TRUNC followed by a store, fold this into a
>    // truncating store.  We can do this even if this is already a truncstore.
>
> Modified: llvm/trunk/test/CodeGen/AArch64/ldst-paired-aliasing.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/ldst-paired-aliasing.ll?rev=322085&r1=322084&r2=322085&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/AArch64/ldst-paired-aliasing.ll (original)
> +++ llvm/trunk/test/CodeGen/AArch64/ldst-paired-aliasing.ll Tue Jan  9 07:23:12 2018
> @@ -10,11 +10,10 @@ declare void @llvm.memset.p0i8.i64(i8* n
>  define i32 @main() local_unnamed_addr #1 {
>  ; Make sure the stores happen in the correct order (the exact instructions could change).
>  ; CHECK-LABEL: main:
> -; CHECK: stp xzr, xzr, [sp, #72]
> +; CHECK: str xzr, [sp, #80]
>  ; CHECK: str w9, [sp, #80]
> -; CHECK: str q0, [sp, #48]
> +; CHECK: stp q0, q0, [sp, #48]
>  ; CHECK: ldr w8, [sp, #48]
> -; CHECK: str q0, [sp, #64]
>
>  for.body.lr.ph.i.i.i.i.i.i63:
>    %b1 = alloca [10 x i32], align 16
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list