[PATCH] D126687: [InstCombine] Fix inbounds preservation when swapping GEPs (PR44206)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 31 02:39:29 PDT 2022


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

When reassociating GEPs, we can only keep inbounds if both original GEPs were inbounds, and their offsets have the same sign. For the sake of simplicity I only handle the case where both offsets are non-negative here.

It would probably be fine to just not preserve inbounds at all here, but as I don't see a compile-time impact for adding the isKnownNonNegative() calls I went with this more conservative approach.

Fixes https://github.com/llvm/llvm-project/issues/44206.


https://reviews.llvm.org/D126687

Files:
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/Transforms/InstCombine/gep-combine-loop-invariant.ll
  llvm/test/Transforms/LoopVectorize/ARM/mve-reductions.ll
  llvm/test/Transforms/LoopVectorize/X86/x86-interleaved-accesses-masked-group.ll
  llvm/test/Transforms/LoopVectorize/X86/x86-interleaved-store-accesses-with-gaps.ll
  llvm/test/Transforms/LoopVectorize/consecutive-ptr-uniforms.ll
  llvm/test/Transforms/LoopVectorize/interleaved-accesses.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126687.433042.patch
Type: text/x-patch
Size: 20430 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220531/445e3cea/attachment.bin>


More information about the llvm-commits mailing list