[llvm] [InstCombine] Strip trailing zero GEP indices (PR #151338)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 30 06:57:26 PDT 2025
================
@@ -215,10 +215,7 @@ define i1 @test10_struct(i32 %x) {
define i1 @test10_struct_noinbounds(i32 %x) {
; CHECK-LABEL: @test10_struct_noinbounds(
-; CHECK-NEXT: [[P:%.*]] = getelementptr [[FOO:%.*]], ptr @GS, i32 [[X:%.*]], i32 0
-; CHECK-NEXT: [[Q:%.*]] = load i32, ptr [[P]], align 4
-; CHECK-NEXT: [[R:%.*]] = icmp eq i32 [[Q]], 9
-; CHECK-NEXT: ret i1 [[R]]
+; CHECK-NEXT: ret i1 false
----------------
nikic wrote:
This looks suspicious, but is correct: We know that zero is the only valid value of `%x`. The replaceGEPIdxWithZero() fold doesn't handle a trailing zero index in this case.
https://github.com/llvm/llvm-project/pull/151338
More information about the llvm-commits
mailing list