[PATCH] D120371: [instcombine] Generalize one-compare rule from foldAllocaCmp for noalias calls
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 23 02:22:50 PST 2022
nikic added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:1035
+ bool captured(const Use *U) override {
+ NumCmps++;
+ if (NumCmps == 1)
----------------
nikic wrote:
> Can you please add an explicit check here that this is an icmp user? I guess you omitted the check on the premise that you have a known icmp user, so if you see a single capture it must be that icmp. That may be true, but the fact that we also have certain non-capturing icmps makes the reasoning here very non-obvious.
Or rather, we should check that this user it the same one we're trying to fold.
And it may be worth pointing out that this critically depends on the fact that captures are per-use, not per-user, so if we do something like `alloc + x == alloc + y`, then we'll end up not folding because we have two capturing uses in the same icmp.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120371/new/
https://reviews.llvm.org/D120371
More information about the llvm-commits
mailing list