[llvm] [SeparateConstOffsetFromGEP] Preserve inbounds flag based on ValueTracking and NUW (PR #130617)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 15 11:56:20 PDT 2025
================
@@ -372,8 +372,8 @@ define ptr @trunk_explicit(ptr %ptr, i64 %idx) {
; CHECK-LABEL: define ptr @trunk_explicit(
; CHECK-SAME: ptr [[PTR:%.*]], i64 [[IDX:%.*]]) {
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[TMP0:%.*]] = getelementptr [[STRUCT0:%.*]], ptr [[PTR]], i64 0, i32 3, i64 [[IDX]], i32 1
-; CHECK-NEXT: [[PTR21:%.*]] = getelementptr i8, ptr [[TMP0]], i64 3216
+; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds [[STRUCT0:%.*]], ptr [[PTR]], i64 0, i32 3, i64 [[IDX]], i32 1
+; CHECK-NEXT: [[PTR21:%.*]] = getelementptr inbounds i8, ptr [[TMP0]], i64 3216
----------------
nikic wrote:
This isn't right. The first index of the original GEP got reassociated into a separate GEP at the end here, which generally cannot preserve inbounds. (Imagine %idx is negative.)
https://github.com/llvm/llvm-project/pull/130617
More information about the llvm-commits
mailing list