[PATCH] D33562: MachineLICM: Add new condition for hoisting of caller preserved registers

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 29 01:32:16 PDT 2017


MatzeB added a comment.

In https://reviews.llvm.org/D33562#766872, @nemanjai wrote:

> In https://reviews.llvm.org/D33562#766121, @MatzeB wrote:
>
> > Instead of introducing yet another target callback, how about some simple heuristic like `MRI.hasOneDef(Reg) && !MRI.getUsedPhysRegsMask().test(Reg)`[1] allowing hoisting up to the point of that definition (which you can find out with `MRI.def_instr_begin(Reg)` or similar).
> >
> > [1] We really oughta rename UsedPhysRegMask to something that makes sense (it's simply the union of call regmask operands in the function).
>
>
> If that does the job, I think it would be great to not have to add another target hook. But to be honest, it doesn't really sound like it will solve this problem. Namely, the call through a function pointer **does** clobber X2 (but restores it on return). So a call of that sort being in the loop will presumably still prevent the global address calculation (which uses X2) from being hoisted out of the loop.


You talk about a call instruction? Is X2 saved and restored in the called function? Then it's just a CSR and should not be mentioned in the clobber list so no problem with my proposal above.


https://reviews.llvm.org/D33562





More information about the llvm-commits mailing list