| Chris Lattner | efa3c82 | 2010-07-08 00:27:05 +0000 | [diff] [blame] | 1 | ; RUN: opt -S -scalarrepl < %s | FileCheck %s |
| 2 | ; PR7437 - Make sure SROA preserves address space of memcpy when |
| 3 | ; hacking on it. |
| 4 | target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" |
| 5 | target triple = "x86_64-apple-darwin10" |
| 6 | |
| 7 | %struct.anon = type { [1 x float] } |
| 8 | |
| Stephen Lin | a76289a | 2013-07-14 01:50:49 +0000 | [diff] [blame] | 9 | ; CHECK-LABEL: define void @Test( |
| David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 10 | ; CHECK: load float, float addrspace(2)* |
| Chris Lattner | efa3c82 | 2010-07-08 00:27:05 +0000 | [diff] [blame] | 11 | ; CHECK-NEXT: fsub float |
| 12 | ; CHECK: store float {{.*}}, float addrspace(2)* |
| 13 | define void @Test(%struct.anon addrspace(2)* %pPtr) nounwind { |
| 14 | entry: |
| 15 | %s = alloca %struct.anon, align 4 ; <%struct.anon*> [#uses=3] |
| David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 16 | %arrayidx = getelementptr inbounds %struct.anon, %struct.anon addrspace(2)* %pPtr, i64 0 ; <%struct.anon addrspace(2)*> [#uses=1] |
| Chris Lattner | efa3c82 | 2010-07-08 00:27:05 +0000 | [diff] [blame] | 17 | %tmp1 = bitcast %struct.anon* %s to i8* ; <i8*> [#uses=1] |
| 18 | %tmp2 = bitcast %struct.anon addrspace(2)* %arrayidx to i8 addrspace(2)* ; <i8 addrspace(2)*> [#uses=1] |
| Pete Cooper | 67cf9a7 | 2015-11-19 05:56:52 +0000 | [diff] [blame] | 19 | call void @llvm.memcpy.p0i8.p2i8.i64(i8* %tmp1, i8 addrspace(2)* %tmp2, i64 4, i32 4, i1 false) |
| David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 20 | %tmp3 = getelementptr inbounds %struct.anon, %struct.anon* %s, i32 0, i32 0 ; <[1 x float]*> [#uses=1] |
| 21 | %arrayidx4 = getelementptr inbounds [1 x float], [1 x float]* %tmp3, i32 0, i64 0 ; <float*> [#uses=2] |
| David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 22 | %tmp5 = load float, float* %arrayidx4 ; <float> [#uses=1] |
| Chris Lattner | efa3c82 | 2010-07-08 00:27:05 +0000 | [diff] [blame] | 23 | %sub = fsub float %tmp5, 5.000000e+00 ; <float> [#uses=1] |
| 24 | store float %sub, float* %arrayidx4 |
| David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 25 | %arrayidx7 = getelementptr inbounds %struct.anon, %struct.anon addrspace(2)* %pPtr, i64 0 ; <%struct.anon addrspace(2)*> [#uses=1] |
| Chris Lattner | efa3c82 | 2010-07-08 00:27:05 +0000 | [diff] [blame] | 26 | %tmp8 = bitcast %struct.anon addrspace(2)* %arrayidx7 to i8 addrspace(2)* ; <i8 addrspace(2)*> [#uses=1] |
| 27 | %tmp9 = bitcast %struct.anon* %s to i8* ; <i8*> [#uses=1] |
| Pete Cooper | 67cf9a7 | 2015-11-19 05:56:52 +0000 | [diff] [blame] | 28 | call void @llvm.memcpy.p2i8.p0i8.i64(i8 addrspace(2)* %tmp8, i8* %tmp9, i64 4, i32 4, i1 false) |
| Chris Lattner | efa3c82 | 2010-07-08 00:27:05 +0000 | [diff] [blame] | 29 | ret void |
| 30 | } |
| 31 | |
| Pete Cooper | 67cf9a7 | 2015-11-19 05:56:52 +0000 | [diff] [blame] | 32 | declare void @llvm.memcpy.p0i8.p2i8.i64(i8* nocapture, i8 addrspace(2)* nocapture, i64, i32, i1) nounwind |
| Chris Lattner | efa3c82 | 2010-07-08 00:27:05 +0000 | [diff] [blame] | 33 | |
| Pete Cooper | 67cf9a7 | 2015-11-19 05:56:52 +0000 | [diff] [blame] | 34 | declare void @llvm.memcpy.p2i8.p0i8.i64(i8 addrspace(2)* nocapture, i8* nocapture, i64, i32, i1) nounwind |
| Chris Lattner | efa3c82 | 2010-07-08 00:27:05 +0000 | [diff] [blame] | 35 | |