[PATCH] D153752: [InstSimplify] Fold icmp comparing GEPs with local allocation
hanbum via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 27 05:27:46 PDT 2023
ParkHanbum updated this revision to Diff 534927.
ParkHanbum added a comment.
updated the code according to nikic's comment.
> This condition isn't wrong, but it's also not as accurate as it could be.
>
> Let's say `LHSSize = 4`, `LHSOffset = 0`, `RHSSize = 2`, `RHSOffset = 2` with `LHSOffset - RHSOffset = -2`. These can be equal.
>
> Then consider `LHSSize = 4`, `LHSOffset = 2`, `RHSSize = 2`, `RHSOffset = 0` with `LHSOffset - RHSOffset = 2`. These cannot be equal.
>
> As you can see, the sign of the result matters and we should not just take the absolute value.
>
> I believe the condition should be `Dist.isNonNegative() ? Dist.ult(LHSSize) : (-Dist).ult(RHSSize)`.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153752/new/
https://reviews.llvm.org/D153752
Files:
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/cmp-alloca-offsets.ll
llvm/test/Transforms/InstSimplify/past-the-end.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153752.534927.patch
Type: text/x-patch
Size: 4447 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230627/17c33dd7/attachment.bin>
More information about the llvm-commits
mailing list