[llvm] [InstCombine] Move nonnull assumptions to the base of a gep (PR #195650)
Nikolas Klauser via llvm-commits
llvm-commits at lists.llvm.org
Mon May 4 06:23:08 PDT 2026
================
@@ -613,6 +613,33 @@ define void @nonnull_only_ephemeral_use(ptr %p) {
ret void
}
+define ptr @nonnull_gep(ptr %p, i64 %i) {
+; DEFAULT-LABEL: @nonnull_gep(
+; DEFAULT-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 [[I:%.*]]
+; DEFAULT-NEXT: call void @llvm.assume(i1 true) [ "nonnull"(ptr [[P2]]) ]
+; DEFAULT-NEXT: ret ptr [[P2]]
+;
+; BUNDLES-LABEL: @nonnull_gep(
+; BUNDLES-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 [[I:%.*]]
+; BUNDLES-NEXT: call void @llvm.assume(i1 true) [ "nonnull"(ptr [[P]]) ]
+; BUNDLES-NEXT: ret ptr [[P2]]
----------------
philnik777 wrote:
I'm pretty sure this is a miscompile with knowledge retention enabled. If I'm wrong I'd be happy to understand why this transform is correct.
https://github.com/llvm/llvm-project/pull/195650
More information about the llvm-commits
mailing list