[llvm-branch-commits] [llvm-branch] r303166 - Merging r296163:
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue May 16 05:48:20 PDT 2017
Author: tstellar
Date: Tue May 16 07:48:20 2017
New Revision: 303166
URL: http://llvm.org/viewvc/llvm-project?rev=303166&view=rev
Log:
Merging r296163:
------------------------------------------------------------------------
r296163 | yaxunl | 2017-02-24 15:27:25 -0500 (Fri, 24 Feb 2017) | 9 lines
[InstCombine] Fix bug in pointer replacement
This optimisation was crashing when there was a chain of more than one bitcast
instruction to replace, as a result of the changes in D27283.
Patch by James Price.
Differential Revision: https://reviews.llvm.org/D30347
------------------------------------------------------------------------
Modified:
llvm/branches/release_40/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
llvm/branches/release_40/test/Transforms/InstCombine/memcpy-addrspace.ll
Modified: llvm/branches/release_40/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp?rev=303166&r1=303165&r2=303166&view=diff
==============================================================================
--- llvm/branches/release_40/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp (original)
+++ llvm/branches/release_40/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp Tue May 16 07:48:20 2017
@@ -306,7 +306,7 @@ void PointerReplacer::replace(Instructio
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");
}
Modified: llvm/branches/release_40/test/Transforms/InstCombine/memcpy-addrspace.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/test/Transforms/InstCombine/memcpy-addrspace.ll?rev=303166&r1=303165&r2=303166&view=diff
==============================================================================
--- llvm/branches/release_40/test/Transforms/InstCombine/memcpy-addrspace.ll (original)
+++ llvm/branches/release_40/test/Transforms/InstCombine/memcpy-addrspace.ll Tue May 16 07:48:20 2017
@@ -21,6 +21,26 @@ entry:
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
More information about the llvm-branch-commits
mailing list