[llvm-dev] Expose aliasing information in getModRefInfo (or viceversa?)
Daniel Berlin via llvm-dev
llvm-dev at lists.llvm.org
Tue Oct 10 11:39:08 PDT 2017
On Tue, Oct 10, 2017 at 10:19 AM, Alina Sbirlea <alina.sbirlea at gmail.com>
wrote:
> I'm trying to understand what is the result we'd seek in the example
> in D38569 (pasting here for quick access)
>
> double f(double a)
> {
> double b;
> double c,d;
> double (*fp) (double) __attribute__ ((const));
>
> /* Partially redundant call */
> if (a < 2.0)
> {
> fp = sin;
> c = fp (a);
> }
> else
> {
> c = 1.0;
> fp = cos;
> }
> d = fp (a);
> return d + c;
> }
>
> the fp call will get pushed into the else branch.
> In the equivalent loop, we could promote it (PRE could promote it too if
> you let it speculate)
> If we determine it is a must-alias of a single thing, we could do the same.
> If we determine it's a must-alias of a set of things, we could do the same
> If we determine it's a must-alias of the live on entry def, etc
>
>
>
> If I understand correctly, the necessary info for fp in this example is:
> isMustAlias (CallSite argument a, Value a) &&
> getModRefBehavior(CallSite)==onlyReadsMemory.
> So adding a MRI_MustMod is insufficient?
>
Sigh
I should have taken the time to give a better example.
The must-alias part is irrelevant to an example (it only requires
read-onlyness)
You said "LICM doesn't move calls, so we'd never really care about
must-alias for promotion". I was just pointing out other things move calls
any may want to know.
If you want an example where the must-alias part would matter:
*a = something
foo(a)
b = *a
If foo mustalias a (and only a) not only can you move foo with a, you can
actually clone foo here, change it to be pass-by-value, and promote the
argument inside of it (if you wanted to).
So you can use this info to, for example, do interprocedural promotion.
> Are we instead looking to set a MRI_Must bit, disjunct of MRI_Mod, and
> test for MRI_Ref&MRI_Must or MRI_Mod&MRI_Must?
>
Yes.
In getModRefInfo(CS, Loc), the MRI_Must bit would then be set if
> doesAccessArgPointees and ArgAlias == MustAlias for all Args, which seems
> correct.
>
alias == MustAlias for Loc, not for all args.
(IE It it returns a singular result about Loc, not a result about all args)
To get the set answer for all args, we'd have to query further.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171010/d1b774a8/attachment.html>
More information about the llvm-dev
mailing list