[PATCH] D67612: [UnrolledInstAnalyzer] Use MSSA to find stored values outside of loop.
    Alina Sbirlea via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Mon Sep 16 12:52:22 PDT 2019
    
    
  
asbirlea added a comment.
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.
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