[llvm] [SeparateConstOffsetFromGEP] Fix incorrect inbounds flag in case of non-negative index but negative offset (PR #190192)

Sergey Kachkov via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 3 06:18:02 PDT 2026


================
@@ -41,8 +41,8 @@ define ptr @sign_bit_clear(ptr %p, i64 %i) {
 ; CHECK-LABEL: @sign_bit_clear(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[IDX:%.*]] = and i64 [[I:%.*]], 9223372036854775807
-; CHECK-NEXT:    [[TMP0:%.*]] = getelementptr inbounds i32, ptr [[P:%.*]], i64 [[IDX]]
-; CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[TMP0]], i64 4
+; CHECK-NEXT:    [[TMP0:%.*]] = getelementptr i32, ptr [[P:%.*]], i64 [[IDX]]
+; CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr i8, ptr [[TMP0]], i64 4
----------------
skachkov-sc wrote:

Agreed, this check was too conservative. I've tried to address this probelm from the other side: check that there is no signed overflow during accumulateByteOffset (so we have small positive offset in bytes, but had huge negative offset in elements before the transform)

https://github.com/llvm/llvm-project/pull/190192


More information about the llvm-commits mailing list