[llvm] [InstCombine] Fix pointer replacement in `foldSelectValueEquivalence` (PR #161701)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 2 11:19:41 PDT 2025
dtcxzyw wrote:
> > > Maybe I'm missing something, but at least from the tests, aren't the three canReplacePointersIfEqual being invoked on the same pointers all the times? Couldn't this be done only once?
> >
> >
> > It is not commutative. You can always replace a pointer with a known dereferencable one.
>
> Sorry, I'm not clear. I do understand isDereferenceablePointer is called on different pointers, though, now, canReplacePointersIfEqual(CmpLHS, CmpRHS) is being called twice (one in ReplaceOldOpWithNewOp, one later), and so is canReplacePointersIfEqual(CmpRHS, CmpLHS). Why cannot this be done once for both the operands?
I will cache the result.
https://github.com/llvm/llvm-project/pull/161701
More information about the llvm-commits
mailing list