[PATCH] D47023: Limit the number of phis in intptr/ptrint folding
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Mon May 21 08:40:21 PDT 2018
This might work and existing test cases should be able to make sure the
behavior is not regressed.
David
On Fri, May 18, 2018 at 5:49 PM Michael Zolotukhin via Phabricator <
reviews at reviews.llvm.org> wrote:
> mzolotukhin added a comment.
>
> I thought about this transformation more, and I no longer think that we
> even need to move it to aggressive-instcombine (or another FunctionPass).
> What we need is to just change it from top-down to bottom-up: i.e. to start
> looking not from phi-nodes, but rather from `inttoptr` instructions. That
> is, the algorithm would look like:
>
> visitIntToPtr(Instruction &I) {
> Value *Def = I.getOperand()
> if (!Def.hasSingleUse())
> return;
> if (isa<PtrToInt>(Def)) { // Simple case without phi - it's probably
> already handled somewhere else, but I'm putting it here for completeness
> I.replaceAllUsesWith(Def.getOperand());
> }
> if (isa<PHINode>(Def)) { // Interesting case where we have a
> phi-node
> if (all operands are PtrToInt with a single use) {
> NewPHI = RewritePHI();
> I.replaceAllUsesWith(NewPHI);
> }
> }
> }
>
> What do you think? Would it work?
>
> PS: Internally we worked around the slowdown, so it's not pressing on us
> anymore.
>
> Michael
>
>
> Repository:
> rL LLVM
>
> https://reviews.llvm.org/D47023
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180521/3d916c24/attachment.html>
More information about the llvm-commits
mailing list