[llvm] [SeparateConstOffsetFromGEP] Fix incorrect inbounds flag in case of non-negative index but negative offset (PR #190192)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 2 10:54:58 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
----------------
efriedma-quic wrote:
We know idx.add is positive: if it was negative, the GEP would overflow. Given that, idx itself is positive, so splitting like this should be fine.
https://github.com/llvm/llvm-project/pull/190192
More information about the llvm-commits
mailing list