[llvm] [InstCombine] Remove Store which has one-use AddrSpaceCastInst as Ptr (#68120) (PR #79565)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 26 08:02:08 PST 2024


================
@@ -345,6 +345,22 @@ define void @store_to_readonly_noalias(ptr readonly noalias %0) {
   ret void
 }
 
+; if ptr which store to is addrspacecast, and its target is alloca. remove it.
+define void @src_store_oneuse_addrspaceast_alloca(ptr align 8 %arg) {
+; CHECK-LABEL: @src_store_oneuse_addrspaceast_alloca(
+; CHECK-NEXT:  bb:
+; CHECK-NEXT:    store ptr poison, ptr null, align 8
+; CHECK-NEXT:    ret void
+;
+bb:
+  %i = alloca ptr, align 8, addrspace(5)
+  %i1 = addrspacecast ptr addrspace(5) %i to ptr
+  store ptr %arg, ptr %i1, align 8
----------------
arsenm wrote:

I mean you changed the handling under the dyn_cast<GetElementPtrInst>. As such I don't see how this could possibly fix anything for the AddrSpaceCastInst case. There's nothing special about AddrSpaceCast specifically. I assume the same would manifest for any transitive pointer user, so I don't understand how this is avoiding the issue 

https://github.com/llvm/llvm-project/pull/79565


More information about the llvm-commits mailing list