[PATCH] D120083: [instsimplify] Generalize offset handling when compare pointers derived from allocas
Augie Fackler via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 18 11:40:38 PST 2022
durin42 added a comment.
In D120083#3330734 <https://reviews.llvm.org/D120083#3330734>, @nikic wrote:
>> I vaguely think there should be a more concise way to write these checks. Anyone see one?
>
> As we're dealing with equality comparisons here, we can subtract a common offset from both sides. So rather than dealing with `LHS + LHSOffset == RHS + RHSOffset`, we can instead deal with `LHS + Offset == RHS`, where `Offset = LHSOffset - RHSOffset`. We should be able to fold that if and only if `Offset > -MinSize(RHS)` and `Offset < MinSize(LHS)`.
>
> Does that sound about right?
It took some work to convince myself, but I think that's right.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120083/new/
https://reviews.llvm.org/D120083
More information about the llvm-commits
mailing list