[PATCH] D144492: [InstCombine] Support multiple comparisons in foldAllocaCmp()

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 21 07:52:17 PST 2023


nikic created this revision.
nikic added reviewers: spatel, reames.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

foldAllocaCmp() needs to fold all comparisons of an alloca at the same time, to ensure that there is a consistent view of the alloca address. Currently, it folds "all" comparisons by limiting to the case where there is only one. This patch switches the algorithm to instead actually collect and fold all comparisons.

Something we need to be careful about here is that there may be comparisons where both sides of the icmp are based on the alloca. Such comparisons are comparing offsets of the alloca, and as such can be ignored here, but shouldn't be folded to false!


https://reviews.llvm.org/D144492

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/lib/Transforms/InstCombine/InstCombineInternal.h
  llvm/test/Transforms/InstCombine/compare-alloca.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144492.499178.patch
Type: text/x-patch
Size: 8670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230221/17f81f9d/attachment.bin>


More information about the llvm-commits mailing list