[PATCH] D120083: [instsimplify] Generalize offset handling when compare pointers derived from allocas

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 17 13:14:30 PST 2022


reames created this revision.
reames added reviewers: nikic, fhahn, lebedev.ri, durin42.
Herald added subscribers: bollu, hiraditya, mcrosier.
reames requested review of this revision.
Herald added a project: LLVM.

This generalizes the offset check used when figuring out if two pointers derived from two different allocas (or one alloca and one global) can be equal.

Specifically, it handles the following cases:

- Both offsets are positive, but one or more crosses into the second object, but by less than the offset on the other pointer.  (i.e. offset b is strictly greater than the offset a can obtain into object b.)
- Both negative offsets
- Mix of negative and positive offsets

I vaguely think there should be a more concise way to write these checks.  Anyone see one?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120083

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: D120083.409768.patch
Type: text/x-patch
Size: 5253 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220217/3fe99f1b/attachment.bin>


More information about the llvm-commits mailing list