[PATCH] D67612: [UnrolledInstAnalyzer] Use MSSA to find stored values outside of loop.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 16 13:27:48 PDT 2019


fhahn added a comment.

In D67612#1671640 <https://reviews.llvm.org/D67612#1671640>, @asbirlea wrote:

> Would something like this work for your purpose?
>
>   if (MSSA) {
>       auto *D = MSSA->getWalker()->getClobberingMemoryAccess(&I);
>       if (MemoryDef *MD = dyn_cast<MemoryDef>(D))
>           if (StoreInst *SI = dyn_cast<StoreInst>(MD->getMemoryInst())) 
>               if (Optional<SimplifiedAddress> MaybeSimpAddr =
>                   simplifyNonLoopAddress(SI->getPointerOperand()))
>                   if (MaybeSimpAddr->Base == AddrBase &&
>                       MaybeSimpAddr->Offset == SimplifiedAddrOp)
>                       return true;
>   }
>
>
> I don't know if you want to `return false;` on some of those branches or continue with the checks below.
>
> The walker will stop at the first access that may alias the Load. If it's not a Def, it's a Phi and it should give up, similarly if it's a Def but not a Store. Then, only if it's a store and has the conditions you added, the load can be folded/cost is ignored.


Yep, but that lets us only look at a single def, right? The load in the loop will be clobbered by multiple store, so the first one returned might not be the one we are interested in. Because we look at the load in a certain iteration, we may be able to simplify the pointer to a base pointer + constant offset. We should be able to skip MemDefs, if we can prove they store to different offsets for the same base pointer.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67612/new/

https://reviews.llvm.org/D67612





More information about the llvm-commits mailing list