[PATCH] D47023: Limit the number of phis in intptr/ptrint folding
Michael Zolotukhin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 18 17:49:49 PDT 2018
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
More information about the llvm-commits
mailing list