1; RUN: opt -S -mtriple=amdgcn-- -data-layout=A5 -amdgpu-promote-alloca -sroa -instcombine < %s | FileCheck -check-prefix=OPT %s
2
3; Should give up promoting alloca to vector with an addrspacecast.
4
5; OPT-LABEL: @vector_addrspacecast(
6; OPT: alloca [3 x i32]
7; OPT: store i32 0, i32 addrspace(5)* %a0, align 4
8; OPT: store i32 1, i32 addrspace(5)* %a1, align 4
9; OPT: store i32 2, i32 addrspace(5)* %a2, align 4
10; OPT: %tmp = getelementptr [3 x i32], [3 x i32] addrspace(5)* %alloca, i64 0, i64 %index
11; OPT: %ac = addrspacecast i32 addrspace(5)* %tmp to i32*
12; OPT: %data = load i32, i32* %ac, align 4
13define amdgpu_kernel void @vector_addrspacecast(i32 addrspace(1)* %out, i64 %index) {
14entry:
15  %alloca = alloca [3 x i32], addrspace(5)
16  %a0 = getelementptr [3 x i32], [3 x i32] addrspace(5)* %alloca, i32 0, i32 0
17  %a1 = getelementptr [3 x i32], [3 x i32] addrspace(5)* %alloca, i32 0, i32 1
18  %a2 = getelementptr [3 x i32], [3 x i32] addrspace(5)* %alloca, i32 0, i32 2
19  store i32 0, i32 addrspace(5)* %a0
20  store i32 1, i32 addrspace(5)* %a1
21  store i32 2, i32 addrspace(5)* %a2
22  %tmp = getelementptr [3 x i32], [3 x i32] addrspace(5)* %alloca, i64 0, i64 %index
23  %ac = addrspacecast i32 addrspace(5)* %tmp to i32 *
24  %data = load i32, i32 * %ac
25  store i32 %data, i32 addrspace(1)* %out
26  ret void
27}
28