[PATCH] D98058: [InstCombine] Simplify phis with incoming pointer-casts.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 8 05:35:27 PST 2021
fhahn added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp:1316
PN.getIncomingValue(0)->hasOneUser())
if (Instruction *Result = foldPHIArgOpIntoPHI(PN))
return Result;
----------------
lebedev.ri wrote:
> I think you want to extend `foldPHIArgOpIntoPHI()`.
I'm not sure. The checks for `foldPHIArgOpIntoPHI` are more restrictive than what is needed for pointer casts I think (e.g. the incoming values need to be instructions with matching opcodes and the first one must only have a single user).
I don't think we need to be that restrictive for most pointer casts. For bit casts/geps, which should effectively be no-ops in the end, it should always be safe to replace a PHI with a bit cast. For `addrspacecast`, that may not be true and replacing a phi might add an extra 'real' instruction (if the incoming values are used elsewhere). I'd prefer to not handle `addrspacecast` here if we can get away with less restrictions in the `bit cast` case.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98058/new/
https://reviews.llvm.org/D98058
More information about the llvm-commits
mailing list