llvm.org GIT mirror llvm / 5ed13a6
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 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_40@303166 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 2 years ago
2 changed file(s) with 21 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
305305 auto *NewI = new BitCastInst(V, NewT);
306306 IC.InsertNewInstWith(NewI, *BC);
307307 NewI->takeName(BC);
308 WorkMap[GEP] = NewI;
308 WorkMap[BC] = NewI;
309309 } else {
310310 llvm_unreachable("should never reach here");
311311 }
1717 %1 = load i32, i32* %arrayidx, align 4
1818 %arrayidx1 = getelementptr inbounds i32, i32 addrspace(1)* %out, i64 %x
1919 store i32 %1, i32 addrspace(1)* %arrayidx1, align 4
20 ret void
21 }
22
23 ; CHECK-LABEL: test_load_bitcast_chain
24 ; CHECK: %[[GEP:.*]] = getelementptr [8 x i32], [8 x i32] addrspace(2)* @test.data, i64 0, i64 %x
25 ; CHECK: %{{.*}} = load i32, i32 addrspace(2)* %[[GEP]]
26 ; CHECK-NOT: alloca
27 ; CHECK-NOT: call void @llvm.memcpy.p0i8.p2i8.i64
28 ; CHECK-NOT: addrspacecast
29 ; CHECK-NOT: load i32, i32*
30 define void @test_load_bitcast_chain(i32 addrspace(1)* %out, i64 %x) {
31 entry:
32 %data = alloca [8 x i32], align 4
33 %0 = bitcast [8 x i32]* %data to i8*
34 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)
35 %1 = bitcast i8* %0 to i32*
36 %arrayidx = getelementptr inbounds i32, i32* %1, i64 %x
37 %2 = load i32, i32* %arrayidx, align 4
38 %arrayidx1 = getelementptr inbounds i32, i32 addrspace(1)* %out, i64 %x
39 store i32 %2, i32 addrspace(1)* %arrayidx1, align 4
2040 ret void
2141 }
2242