[PATCH] D28137: [Devirtualization] MemDep returns non-local !invariant.group dependencies

Piotr Padlewski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 30 10:25:34 PST 2016


Prazek added a comment.

In https://reviews.llvm.org/D28137#632782, @reames wrote:

> The use of a side cache here appears unnecessary.  Why can't you simply return the non-local result to the immediate caller and let it be kept in a local unless needed?


What do you mean by "kept in local"? Do you mean storing one def as a member of MemDep?

> Also, you have a problem with the quality of your results.  You're returning the first non-local found, not the best non-local found.  This makes the results use list order dependent.  We generally try not to have use list order sensitivities in the optimizer.

But this doesn't matter to invariant.group. Let say that I have 2 loads with invariant group, one local and second non-local

    %0 load %a !invariant.group !0
    call void foo(%a)
    br b1
  
  b1:
    %1 = load %a !invariant.group !0
    call void foo(%a)
    %2 = load %a !invariant.group !0

There is guarantee that %0, %1 and %2 will load the same value. If I will ask for dependency about %2, then whenever I will get
def(%1) or def(%0), they will be transformed into either %0 or %1, but assuming we will query %1, then it will be changed into %0,
which means that we will end up with %0 everywhere.
This is assuming that GVN is sane.

I can continue looping and either try hard to find local dependency or 'the best' non-local dependency (which probably won't be found because GVN will already remove it)
and return it, or even collect list of all non local dependencies.

I am also not sure if I understand what 'the best' non local dependency means.


https://reviews.llvm.org/D28137





More information about the llvm-commits mailing list