[all-commits] [llvm/llvm-project] b0516c: [SeparateConstOffsetFromGEP] Set `inbounds` correc...

Justin Lebar via All-commits all-commits at lists.llvm.org
Wed May 27 14:20:47 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b0516c58736cf1d83188e0b04cf5acb123e382e4
      https://github.com/llvm/llvm-project/commit/b0516c58736cf1d83188e0b04cf5acb123e382e4
  Author: Justin Lebar <justin.lebar at gmail.com>
  Date:   2026-05-27 (Wed, 27 May 2026)

  Changed paths:
    M llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
    M llvm/test/Transforms/SeparateConstOffsetFromGEP/AMDGPU/lower-gep.ll
    M llvm/test/Transforms/SeparateConstOffsetFromGEP/split-gep-sub.ll

  Log Message:
  -----------
  [SeparateConstOffsetFromGEP] Set `inbounds` correctly. (#199304)

swapGEPOperand reorders the GEPs (ptr+off)+const into (ptr+const)+off.
When it does so, it needs to determine if the inner GEP is inbounds.

Previously the way it did this was to call
stripAndAccumulateInBoundsConstantOffsets on (ptr+const), and then check
if this offset was indeed in-bounds.

However, this GEP was not necessarily marked as `inbounds` itself. If it
was not, stripAndAccumulateInBoundsConstantOffsets would return 0 for
the offset (instead of `const`), in which case we'd check if
`0 < [obj width]`, which is trivially true, and then incorrectly mark
the GEP as inbounds.

This bug was found by a large run of Opus 4.7 looking for bugs in LLVM.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list