[PATCH] D30347: [InstCombine] Fix bug in pointer replacement

Yaxun Liu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 24 12:39:16 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL296163: [InstCombine] Fix bug in pointer replacement (authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D30347?vs=89702&id=89709#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30347

Files:
  llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
  llvm/trunk/test/Transforms/InstCombine/memcpy-addrspace.ll


Index: llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
===================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -309,7 +309,7 @@
     auto *NewI = new BitCastInst(V, NewT);
     IC.InsertNewInstWith(NewI, *BC);
     NewI->takeName(BC);
-    WorkMap[GEP] = NewI;
+    WorkMap[BC] = NewI;
   } else {
     llvm_unreachable("should never reach here");
   }
Index: llvm/trunk/test/Transforms/InstCombine/memcpy-addrspace.ll
===================================================================
--- llvm/trunk/test/Transforms/InstCombine/memcpy-addrspace.ll
+++ llvm/trunk/test/Transforms/InstCombine/memcpy-addrspace.ll
@@ -21,6 +21,26 @@
   ret void
 }
 
+; CHECK-LABEL: test_load_bitcast_chain
+; CHECK: %[[GEP:.*]] = getelementptr [8 x i32], [8 x i32] addrspace(2)* @test.data, i64 0, i64 %x
+; CHECK: %{{.*}} = load i32, i32 addrspace(2)* %[[GEP]]
+; CHECK-NOT: alloca
+; CHECK-NOT: call void @llvm.memcpy.p0i8.p2i8.i64
+; CHECK-NOT: addrspacecast
+; CHECK-NOT: load i32, i32*
+define void @test_load_bitcast_chain(i32 addrspace(1)* %out, i64 %x) {
+entry:
+  %data = alloca [8 x i32], align 4
+  %0 = bitcast [8 x i32]* %data to i8*
+  call void @llvm.memcpy.p0i8.p2i8.i64(i8* %0, i8 addrspace(2)* bitcast ([8 x i32] addrspace(2)* @test.data to i8 addrspace(2)*), i64 32, i32 4, i1 false)
+  %1 = bitcast i8* %0 to i32*
+  %arrayidx = getelementptr inbounds i32, i32* %1, i64 %x
+  %2 = load i32, i32* %arrayidx, align 4
+  %arrayidx1 = getelementptr inbounds i32, i32 addrspace(1)* %out, i64 %x
+  store i32 %2, i32 addrspace(1)* %arrayidx1, align 4
+  ret void
+}
+
 ; CHECK-LABEL: test_call
 ; CHECK: alloca
 ; CHECK: call void @llvm.memcpy.p0i8.p2i8.i64


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30347.89709.patch
Type: text/x-patch
Size: 1838 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170224/4650108d/attachment.bin>


More information about the llvm-commits mailing list