[PATCH] D136201: [InstCombine] Handle PHI nodes when eliminating constant memcpy
Anshil Gandhi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 11 13:33:45 PST 2022
gandhi21299 marked 4 inline comments as done.
gandhi21299 added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:60
+ if (PHI->getType()->getPointerAddressSpace() == 0 &&
+ TheCopy->getSourceAddressSpace())
+ return false;
----------------
nikic wrote:
> Why do we care about default address space here? I think what you probably want to check is `PHI->getType()->getPointerAddressSpace() != TheCopy->getPointerAddressSpace()`? But also, this code assumes that `TheCopy` is available before the PHI is seen, and I don't think anything guarantees that -- order of uses is unpredictable. I think you'd want to perform the bailout in `PointerReplacer::collectUsers()` instead? Maybe I'm misunderstanding the purpose here.
I implemented it for the function @addrspace_diff_keep_alloca in the test file. I improved upon the solution by moving the changes over to `collectUsers()` which does make a lot more sense wrt my previous solution. I hope it seems fine now.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136201/new/
https://reviews.llvm.org/D136201
More information about the llvm-commits
mailing list