[PATCH] D24517: GVN-hoist: fix store past load dependence analysis (PR30216)

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 13 16:38:10 PDT 2016


>
>
>> I'm not sure the MemSSA will have all the links to be able to walk
>> the WAR dependences.
>>
>
> It does not.
>

Actually, you can build a walker already that will give you war dependence
info.

Here is the pseudo code for a getClobberingAccess (note that it is faster
to build the entire aliased load set than to call this multiple times.
Noted below what to change to do that).  Note that it assumes transitivity
in aliasing, but this is easy to fix by changing the outerworklist to also
include store uses.

Initialize OuterWorklist to be
cachingWalker->getClobberingAccess(OriginalStore)
while (!OuterWorklist.empty())
  CurrentStore = OuterWorklist.pop_front();

  // Any load that is aliased with the store must be a user of the store in
use-optimized memoryssa
  for each User of CurrentStore:
    if (isa<MemoryUse>(User))
      UseWorklist.push_back(User)

  while (!UseWorklist.empty())
    CurrentAccess = UseWorklist.pop_front();
    if (StoreClobbersLoad(OriginalStore, CurrentAccess)) // This is
instructionClobbersQuery, basically
        return CurrentAccess // If you change this to insert it into a set
instead of returning, you can get the entire set of dominating aliased loads

  // Keep going up until we've gotten past the attempted hoist point
  if (!MSSA->dominates(CurrentStore, HoistPoint))

OuterWorklist.push_back(cachingWalker->getClobberingAccess(CurrentStore->getDefiningAccess()))


Note that this should check <= the number of loads than a version that
walks all loads does.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160913/03a8f48c/attachment.html>


More information about the llvm-commits mailing list