[llvm] IR: Add nonnull flag to addrspacecast (PR #217903)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 21 14:01:18 PDT 2026
================
@@ -53,3 +53,22 @@ define void @multiuse_addrspacecast_gep_addrspacecast(ptr addrspace(3) %ptr) {
store i32 8, ptr addrspace(3) %asc1, align 8
ret void
}
+
+; nonnull is dropped when the cast is rebuilt on the sunk select operand.
+; CHECK-LABEL: @rebuilt_addrspacecast_drops_nonnull(
+; CHECK: %sel = select i1 %c, ptr addrspace(3) %p, ptr addrspace(3) %q
+; CHECK-NEXT: %1 = addrspacecast ptr addrspace(3) %sel to ptr
+; CHECK-NOT: nonnull
----------------
arsenm wrote:
It also turns out to be hard to implement this preservation correctly. The Values go into a big map, and we don't know the specific use context position to know if the non null assertion is valid. A similar problem exists for how assumes were implemented such that they only work on instructions and not arguments or anything else
https://github.com/llvm/llvm-project/pull/217903
More information about the llvm-commits
mailing list