[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 02:04:10 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:

This test case doesn't contain a getelementptr. I don't see how anything could have gone wrong previously? Either way, should have a test with and without GEP 

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


More information about the llvm-commits mailing list