10efdd06bSMatt Arsenault; RUN: llc -show-mc-encoding -mattr=+promote-alloca -amdgpu-load-store-vectorizer=0 -verify-machineinstrs -march=amdgcn < %s | FileCheck %s -check-prefix=SI-PROMOTE -check-prefix=SI -check-prefix=FUNC
20efdd06bSMatt Arsenault; RUN: llc -show-mc-encoding -mattr=+promote-alloca -amdgpu-load-store-vectorizer=0 -verify-machineinstrs -mtriple=amdgcn--amdhsa -mcpu=kaveri -mattr=-unaligned-buffer-access < %s | FileCheck %s -check-prefix=SI-PROMOTE -check-prefix=SI -check-prefix=FUNC -check-prefix=HSA-PROMOTE
30efdd06bSMatt Arsenault; RUN: llc -show-mc-encoding -mattr=-promote-alloca -amdgpu-load-store-vectorizer=0 -verify-machineinstrs -march=amdgcn < %s | FileCheck %s -check-prefix=SI-ALLOCA -check-prefix=SI -check-prefix=FUNC
40efdd06bSMatt Arsenault; RUN: llc -show-mc-encoding -mattr=-promote-alloca -amdgpu-load-store-vectorizer=0 -verify-machineinstrs -mtriple=amdgcn-amdhsa -mcpu=kaveri -mattr=-unaligned-buffer-access < %s | FileCheck %s -check-prefix=SI-ALLOCA -check-prefix=SI -check-prefix=FUNC -check-prefix=HSA-ALLOCA
50efdd06bSMatt Arsenault; RUN: llc -show-mc-encoding -mattr=+promote-alloca -amdgpu-load-store-vectorizer=0 -verify-machineinstrs -mtriple=amdgcn-amdhsa -march=amdgcn -mcpu=tonga -mattr=-unaligned-buffer-access < %s | FileCheck %s -check-prefix=SI-PROMOTE -check-prefix=SI -check-prefix=FUNC
60efdd06bSMatt Arsenault; RUN: llc -show-mc-encoding -mattr=-promote-alloca -amdgpu-load-store-vectorizer=0 -verify-machineinstrs -mtriple=amdgcn-amdhsa -march=amdgcn -mcpu=tonga -mattr=-unaligned-buffer-access < %s | FileCheck %s -check-prefix=SI-ALLOCA -check-prefix=SI -check-prefix=FUNC
723dcd6e0SJan Vesely
823dcd6e0SJan Vesely; RUN: opt -S -mtriple=amdgcn-unknown-amdhsa -mcpu=kaveri -amdgpu-promote-alloca < %s | FileCheck -check-prefix=HSAOPT -check-prefix=OPT %s
923dcd6e0SJan Vesely; RUN: opt -S -mtriple=amdgcn-unknown-unknown -mcpu=kaveri -amdgpu-promote-alloca < %s | FileCheck -check-prefix=NOHSAOPT -check-prefix=OPT %s
1023dcd6e0SJan Vesely
11c438ef57SMatt Arsenault; RUN: llc -march=r600 -mcpu=cypress < %s | FileCheck %s -check-prefix=R600 -check-prefix=FUNC
12c438ef57SMatt Arsenault
13c438ef57SMatt Arsenault
1423dcd6e0SJan Vesely; HSAOPT: @mova_same_clause.stack = internal unnamed_addr addrspace(3) global [256 x [5 x i32]] undef, align 4
1523dcd6e0SJan Vesely; HSAOPT: @high_alignment.stack = internal unnamed_addr addrspace(3) global [256 x [8 x i32]] undef, align 16
1623dcd6e0SJan Vesely
1723dcd6e0SJan Vesely
1823dcd6e0SJan Vesely; FUNC-LABEL: {{^}}mova_same_clause:
1923dcd6e0SJan Vesely; OPT-LABEL: @mova_same_clause(
2023dcd6e0SJan Vesely
2123dcd6e0SJan Vesely; R600: LDS_WRITE
2223dcd6e0SJan Vesely; R600: LDS_WRITE
2323dcd6e0SJan Vesely; R600: LDS_READ
2423dcd6e0SJan Vesely; R600: LDS_READ
2523dcd6e0SJan Vesely
2623dcd6e0SJan Vesely; HSA-PROMOTE: .amd_kernel_code_t
2723dcd6e0SJan Vesely; HSA-PROMOTE: workgroup_group_segment_byte_size = 5120
2823dcd6e0SJan Vesely; HSA-PROMOTE: .end_amd_kernel_code_t
2923dcd6e0SJan Vesely
3023dcd6e0SJan Vesely; FIXME: These should be merged
3123dcd6e0SJan Vesely; HSA-PROMOTE: s_load_dword s{{[0-9]+}}, s[4:5], 0x1
3223dcd6e0SJan Vesely; HSA-PROMOTE: s_load_dword s{{[0-9]+}}, s[4:5], 0x2
3323dcd6e0SJan Vesely
3423dcd6e0SJan Vesely; SI-PROMOTE: ds_write_b32
3523dcd6e0SJan Vesely; SI-PROMOTE: ds_write_b32
3623dcd6e0SJan Vesely; SI-PROMOTE: ds_read_b32
3723dcd6e0SJan Vesely; SI-PROMOTE: ds_read_b32
3823dcd6e0SJan Vesely
3923dcd6e0SJan Vesely; HSA-ALLOCA: .amd_kernel_code_t
4023dcd6e0SJan Vesely; FIXME: Creating the emergency stack slots causes us to over-estimate scratch
4123dcd6e0SJan Vesely; by 4 bytes.
4223dcd6e0SJan Vesely; HSA-ALLOCA: workitem_private_segment_byte_size = 24
4323dcd6e0SJan Vesely; HSA-ALLOCA: .end_amd_kernel_code_t
4423dcd6e0SJan Vesely
4523dcd6e0SJan Vesely; HSA-ALLOCA: s_mov_b32 flat_scratch_lo, s7
4623dcd6e0SJan Vesely; HSA-ALLOCA: s_add_u32 s6, s6, s9
4723dcd6e0SJan Vesely; HSA-ALLOCA: s_lshr_b32 flat_scratch_hi, s6, 8
4823dcd6e0SJan Vesely
4923dcd6e0SJan Vesely; SI-ALLOCA: buffer_store_dword v{{[0-9]+}}, v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}} offen ; encoding: [0x00,0x10,0x70,0xe0
5023dcd6e0SJan Vesely; SI-ALLOCA: buffer_store_dword v{{[0-9]+}}, v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}} offen ; encoding: [0x00,0x10,0x70,0xe0
5123dcd6e0SJan Vesely
5223dcd6e0SJan Vesely
5323dcd6e0SJan Vesely; HSAOPT: [[DISPATCH_PTR:%[0-9]+]] = call noalias nonnull dereferenceable(64) i8 addrspace(2)* @llvm.amdgcn.dispatch.ptr()
5423dcd6e0SJan Vesely; HSAOPT: [[CAST_DISPATCH_PTR:%[0-9]+]] = bitcast i8 addrspace(2)* [[DISPATCH_PTR]] to i32 addrspace(2)*
5523dcd6e0SJan Vesely; HSAOPT: [[GEP0:%[0-9]+]] = getelementptr inbounds i32, i32 addrspace(2)* [[CAST_DISPATCH_PTR]], i64 1
5623dcd6e0SJan Vesely; HSAOPT: [[LDXY:%[0-9]+]] = load i32, i32 addrspace(2)* [[GEP0]], align 4, !invariant.load !0
5723dcd6e0SJan Vesely; HSAOPT: [[GEP1:%[0-9]+]] = getelementptr inbounds i32, i32 addrspace(2)* [[CAST_DISPATCH_PTR]], i64 2
5823dcd6e0SJan Vesely; HSAOPT: [[LDZU:%[0-9]+]] = load i32, i32 addrspace(2)* [[GEP1]], align 4, !range !1, !invariant.load !0
5923dcd6e0SJan Vesely; HSAOPT: [[EXTRACTY:%[0-9]+]] = lshr i32 [[LDXY]], 16
6023dcd6e0SJan Vesely
6123dcd6e0SJan Vesely; HSAOPT: [[WORKITEM_ID_X:%[0-9]+]] = call i32 @llvm.amdgcn.workitem.id.x(), !range !1
6223dcd6e0SJan Vesely; HSAOPT: [[WORKITEM_ID_Y:%[0-9]+]] = call i32 @llvm.amdgcn.workitem.id.y(), !range !1
6323dcd6e0SJan Vesely; HSAOPT: [[WORKITEM_ID_Z:%[0-9]+]] = call i32 @llvm.amdgcn.workitem.id.z(), !range !1
6423dcd6e0SJan Vesely
6523dcd6e0SJan Vesely; HSAOPT: [[Y_SIZE_X_Z_SIZE:%[0-9]+]] = mul nuw nsw i32 [[EXTRACTY]], [[LDZU]]
6623dcd6e0SJan Vesely; HSAOPT: [[YZ_X_XID:%[0-9]+]] = mul i32 [[Y_SIZE_X_Z_SIZE]], [[WORKITEM_ID_X]]
6723dcd6e0SJan Vesely; HSAOPT: [[Y_X_Z_SIZE:%[0-9]+]] = mul nuw nsw i32 [[WORKITEM_ID_Y]], [[LDZU]]
6823dcd6e0SJan Vesely; HSAOPT: [[ADD_YZ_X_X_YZ_SIZE:%[0-9]+]] = add i32 [[YZ_X_XID]], [[Y_X_Z_SIZE]]
6923dcd6e0SJan Vesely; HSAOPT: [[ADD_ZID:%[0-9]+]] = add i32 [[ADD_YZ_X_X_YZ_SIZE]], [[WORKITEM_ID_Z]]
7023dcd6e0SJan Vesely
7123dcd6e0SJan Vesely; HSAOPT: [[LOCAL_GEP:%[0-9]+]] = getelementptr inbounds [256 x [5 x i32]], [256 x [5 x i32]] addrspace(3)* @mova_same_clause.stack, i32 0, i32 [[ADD_ZID]]
7223dcd6e0SJan Vesely; HSAOPT: %arrayidx1 = getelementptr inbounds [5 x i32], [5 x i32] addrspace(3)* [[LOCAL_GEP]], i32 0, i32 {{%[0-9]+}}
7323dcd6e0SJan Vesely; HSAOPT: %arrayidx3 = getelementptr inbounds [5 x i32], [5 x i32] addrspace(3)* [[LOCAL_GEP]], i32 0, i32 {{%[0-9]+}}
7423dcd6e0SJan Vesely; HSAOPT: %arrayidx10 = getelementptr inbounds [5 x i32], [5 x i32] addrspace(3)* [[LOCAL_GEP]], i32 0, i32 0
7523dcd6e0SJan Vesely; HSAOPT: %arrayidx12 = getelementptr inbounds [5 x i32], [5 x i32] addrspace(3)* [[LOCAL_GEP]], i32 0, i32 1
7623dcd6e0SJan Vesely
7723dcd6e0SJan Vesely
7823dcd6e0SJan Vesely; NOHSAOPT: call i32 @llvm.r600.read.local.size.y(), !range !0
7923dcd6e0SJan Vesely; NOHSAOPT: call i32 @llvm.r600.read.local.size.z(), !range !0
8023dcd6e0SJan Vesely; NOHSAOPT: call i32 @llvm.amdgcn.workitem.id.x(), !range !0
8123dcd6e0SJan Vesely; NOHSAOPT: call i32 @llvm.amdgcn.workitem.id.y(), !range !0
8223dcd6e0SJan Vesely; NOHSAOPT: call i32 @llvm.amdgcn.workitem.id.z(), !range !0
838a028bf4SMatt Arsenaultdefine void @mova_same_clause(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) #0 {
8423dcd6e0SJan Veselyentry:
8523dcd6e0SJan Vesely  %stack = alloca [5 x i32], align 4
8623dcd6e0SJan Vesely  %0 = load i32, i32 addrspace(1)* %in, align 4
8723dcd6e0SJan Vesely  %arrayidx1 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %0
8823dcd6e0SJan Vesely  store i32 4, i32* %arrayidx1, align 4
8923dcd6e0SJan Vesely  %arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %in, i32 1
9023dcd6e0SJan Vesely  %1 = load i32, i32 addrspace(1)* %arrayidx2, align 4
9123dcd6e0SJan Vesely  %arrayidx3 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %1
9223dcd6e0SJan Vesely  store i32 5, i32* %arrayidx3, align 4
9323dcd6e0SJan Vesely  %arrayidx10 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 0
9423dcd6e0SJan Vesely  %2 = load i32, i32* %arrayidx10, align 4
9523dcd6e0SJan Vesely  store i32 %2, i32 addrspace(1)* %out, align 4
9623dcd6e0SJan Vesely  %arrayidx12 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 1
9723dcd6e0SJan Vesely  %3 = load i32, i32* %arrayidx12
9823dcd6e0SJan Vesely  %arrayidx13 = getelementptr inbounds i32, i32 addrspace(1)* %out, i32 1
9923dcd6e0SJan Vesely  store i32 %3, i32 addrspace(1)* %arrayidx13
10023dcd6e0SJan Vesely  ret void
10123dcd6e0SJan Vesely}
10223dcd6e0SJan Vesely
10323dcd6e0SJan Vesely; OPT-LABEL: @high_alignment(
10423dcd6e0SJan Vesely; OPT: getelementptr inbounds [256 x [8 x i32]], [256 x [8 x i32]] addrspace(3)* @high_alignment.stack, i32 0, i32 %{{[0-9]+}}
1058a028bf4SMatt Arsenaultdefine void @high_alignment(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) #0 {
10623dcd6e0SJan Veselyentry:
10723dcd6e0SJan Vesely  %stack = alloca [8 x i32], align 16
10823dcd6e0SJan Vesely  %0 = load i32, i32 addrspace(1)* %in, align 4
10923dcd6e0SJan Vesely  %arrayidx1 = getelementptr inbounds [8 x i32], [8 x i32]* %stack, i32 0, i32 %0
11023dcd6e0SJan Vesely  store i32 4, i32* %arrayidx1, align 4
11123dcd6e0SJan Vesely  %arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %in, i32 1
11223dcd6e0SJan Vesely  %1 = load i32, i32 addrspace(1)* %arrayidx2, align 4
11323dcd6e0SJan Vesely  %arrayidx3 = getelementptr inbounds [8 x i32], [8 x i32]* %stack, i32 0, i32 %1
11423dcd6e0SJan Vesely  store i32 5, i32* %arrayidx3, align 4
11523dcd6e0SJan Vesely  %arrayidx10 = getelementptr inbounds [8 x i32], [8 x i32]* %stack, i32 0, i32 0
11623dcd6e0SJan Vesely  %2 = load i32, i32* %arrayidx10, align 4
11723dcd6e0SJan Vesely  store i32 %2, i32 addrspace(1)* %out, align 4
11823dcd6e0SJan Vesely  %arrayidx12 = getelementptr inbounds [8 x i32], [8 x i32]* %stack, i32 0, i32 1
11923dcd6e0SJan Vesely  %3 = load i32, i32* %arrayidx12
12023dcd6e0SJan Vesely  %arrayidx13 = getelementptr inbounds i32, i32 addrspace(1)* %out, i32 1
12123dcd6e0SJan Vesely  store i32 %3, i32 addrspace(1)* %arrayidx13
12223dcd6e0SJan Vesely  ret void
12323dcd6e0SJan Vesely}
12423dcd6e0SJan Vesely
12523dcd6e0SJan Vesely; FUNC-LABEL: {{^}}no_replace_inbounds_gep:
12623dcd6e0SJan Vesely; OPT-LABEL: @no_replace_inbounds_gep(
12723dcd6e0SJan Vesely; OPT: alloca [5 x i32]
12823dcd6e0SJan Vesely
12923dcd6e0SJan Vesely; SI-NOT: ds_write
1308a028bf4SMatt Arsenaultdefine void @no_replace_inbounds_gep(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) #0 {
13123dcd6e0SJan Veselyentry:
13223dcd6e0SJan Vesely  %stack = alloca [5 x i32], align 4
13323dcd6e0SJan Vesely  %0 = load i32, i32 addrspace(1)* %in, align 4
13423dcd6e0SJan Vesely  %arrayidx1 = getelementptr [5 x i32], [5 x i32]* %stack, i32 0, i32 %0
13523dcd6e0SJan Vesely  store i32 4, i32* %arrayidx1, align 4
13623dcd6e0SJan Vesely  %arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %in, i32 1
13723dcd6e0SJan Vesely  %1 = load i32, i32 addrspace(1)* %arrayidx2, align 4
13823dcd6e0SJan Vesely  %arrayidx3 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %1
13923dcd6e0SJan Vesely  store i32 5, i32* %arrayidx3, align 4
14023dcd6e0SJan Vesely  %arrayidx10 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 0
14123dcd6e0SJan Vesely  %2 = load i32, i32* %arrayidx10, align 4
14223dcd6e0SJan Vesely  store i32 %2, i32 addrspace(1)* %out, align 4
14323dcd6e0SJan Vesely  %arrayidx12 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 1
14423dcd6e0SJan Vesely  %3 = load i32, i32* %arrayidx12
14523dcd6e0SJan Vesely  %arrayidx13 = getelementptr inbounds i32, i32 addrspace(1)* %out, i32 1
14623dcd6e0SJan Vesely  store i32 %3, i32 addrspace(1)* %arrayidx13
14723dcd6e0SJan Vesely  ret void
14823dcd6e0SJan Vesely}
14923dcd6e0SJan Vesely
15023dcd6e0SJan Vesely; This test checks that the stack offset is calculated correctly for structs.
15123dcd6e0SJan Vesely; All register loads/stores should be optimized away, so there shouldn't be
15223dcd6e0SJan Vesely; any MOVA instructions.
15323dcd6e0SJan Vesely;
15423dcd6e0SJan Vesely; XXX: This generated code has unnecessary MOVs, we should be able to optimize
15523dcd6e0SJan Vesely; this.
15623dcd6e0SJan Vesely
15723dcd6e0SJan Vesely; FUNC-LABEL: {{^}}multiple_structs:
15823dcd6e0SJan Vesely; OPT-LABEL: @multiple_structs(
15923dcd6e0SJan Vesely
16023dcd6e0SJan Vesely; R600-NOT: MOVA_INT
16123dcd6e0SJan Vesely; SI-NOT: v_movrel
16223dcd6e0SJan Vesely; SI-NOT: v_movrel
16323dcd6e0SJan Vesely%struct.point = type { i32, i32 }
16423dcd6e0SJan Vesely
1658a028bf4SMatt Arsenaultdefine void @multiple_structs(i32 addrspace(1)* %out) #0 {
16623dcd6e0SJan Veselyentry:
16723dcd6e0SJan Vesely  %a = alloca %struct.point
16823dcd6e0SJan Vesely  %b = alloca %struct.point
16923dcd6e0SJan Vesely  %a.x.ptr = getelementptr %struct.point, %struct.point* %a, i32 0, i32 0
17023dcd6e0SJan Vesely  %a.y.ptr = getelementptr %struct.point, %struct.point* %a, i32 0, i32 1
17123dcd6e0SJan Vesely  %b.x.ptr = getelementptr %struct.point, %struct.point* %b, i32 0, i32 0
17223dcd6e0SJan Vesely  %b.y.ptr = getelementptr %struct.point, %struct.point* %b, i32 0, i32 1
17323dcd6e0SJan Vesely  store i32 0, i32* %a.x.ptr
17423dcd6e0SJan Vesely  store i32 1, i32* %a.y.ptr
17523dcd6e0SJan Vesely  store i32 2, i32* %b.x.ptr
17623dcd6e0SJan Vesely  store i32 3, i32* %b.y.ptr
17723dcd6e0SJan Vesely  %a.indirect.ptr = getelementptr %struct.point, %struct.point* %a, i32 0, i32 0
17823dcd6e0SJan Vesely  %b.indirect.ptr = getelementptr %struct.point, %struct.point* %b, i32 0, i32 0
17923dcd6e0SJan Vesely  %a.indirect = load i32, i32* %a.indirect.ptr
18023dcd6e0SJan Vesely  %b.indirect = load i32, i32* %b.indirect.ptr
18123dcd6e0SJan Vesely  %0 = add i32 %a.indirect, %b.indirect
18223dcd6e0SJan Vesely  store i32 %0, i32 addrspace(1)* %out
18323dcd6e0SJan Vesely  ret void
18423dcd6e0SJan Vesely}
18523dcd6e0SJan Vesely
18623dcd6e0SJan Vesely; Test direct access of a private array inside a loop.  The private array
18723dcd6e0SJan Vesely; loads and stores should be lowered to copies, so there shouldn't be any
18823dcd6e0SJan Vesely; MOVA instructions.
18923dcd6e0SJan Vesely
19023dcd6e0SJan Vesely; FUNC-LABEL: {{^}}direct_loop:
19123dcd6e0SJan Vesely; R600-NOT: MOVA_INT
19223dcd6e0SJan Vesely; SI-NOT: v_movrel
19323dcd6e0SJan Vesely
1948a028bf4SMatt Arsenaultdefine void @direct_loop(i32 addrspace(1)* %out, i32 addrspace(1)* %in) #0 {
19523dcd6e0SJan Veselyentry:
19623dcd6e0SJan Vesely  %prv_array_const = alloca [2 x i32]
19723dcd6e0SJan Vesely  %prv_array = alloca [2 x i32]
19823dcd6e0SJan Vesely  %a = load i32, i32 addrspace(1)* %in
19923dcd6e0SJan Vesely  %b_src_ptr = getelementptr inbounds i32, i32 addrspace(1)* %in, i32 1
20023dcd6e0SJan Vesely  %b = load i32, i32 addrspace(1)* %b_src_ptr
20123dcd6e0SJan Vesely  %a_dst_ptr = getelementptr inbounds [2 x i32], [2 x i32]* %prv_array_const, i32 0, i32 0
20223dcd6e0SJan Vesely  store i32 %a, i32* %a_dst_ptr
20323dcd6e0SJan Vesely  %b_dst_ptr = getelementptr inbounds [2 x i32], [2 x i32]* %prv_array_const, i32 0, i32 1
20423dcd6e0SJan Vesely  store i32 %b, i32* %b_dst_ptr
20523dcd6e0SJan Vesely  br label %for.body
20623dcd6e0SJan Vesely
20723dcd6e0SJan Veselyfor.body:
20823dcd6e0SJan Vesely  %inc = phi i32 [0, %entry], [%count, %for.body]
20923dcd6e0SJan Vesely  %x_ptr = getelementptr inbounds [2 x i32], [2 x i32]* %prv_array_const, i32 0, i32 0
21023dcd6e0SJan Vesely  %x = load i32, i32* %x_ptr
21123dcd6e0SJan Vesely  %y_ptr = getelementptr inbounds [2 x i32], [2 x i32]* %prv_array, i32 0, i32 0
21223dcd6e0SJan Vesely  %y = load i32, i32* %y_ptr
21323dcd6e0SJan Vesely  %xy = add i32 %x, %y
21423dcd6e0SJan Vesely  store i32 %xy, i32* %y_ptr
21523dcd6e0SJan Vesely  %count = add i32 %inc, 1
21623dcd6e0SJan Vesely  %done = icmp eq i32 %count, 4095
21723dcd6e0SJan Vesely  br i1 %done, label %for.end, label %for.body
21823dcd6e0SJan Vesely
21923dcd6e0SJan Veselyfor.end:
22023dcd6e0SJan Vesely  %value_ptr = getelementptr inbounds [2 x i32], [2 x i32]* %prv_array, i32 0, i32 0
22123dcd6e0SJan Vesely  %value = load i32, i32* %value_ptr
22223dcd6e0SJan Vesely  store i32 %value, i32 addrspace(1)* %out
22323dcd6e0SJan Vesely  ret void
22423dcd6e0SJan Vesely}
22523dcd6e0SJan Vesely
22623dcd6e0SJan Vesely; FUNC-LABEL: {{^}}short_array:
22723dcd6e0SJan Vesely
22823dcd6e0SJan Vesely; R600: MOVA_INT
22923dcd6e0SJan Vesely
230*39787bdcSMatt Arsenault; SI-PROMOTE-DAG: buffer_store_short v{{[0-9]+}}, off, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}} ; encoding: [0x00,0x00,0x68,0xe0
231*39787bdcSMatt Arsenault; SI-PROMOTE-DAG: buffer_store_short v{{[0-9]+}}, off, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}} offset:2 ; encoding: [0x02,0x00,0x68,0xe0
23212559441SBjorn Pettersson; Loaded value is 0 or 1, so sext will become zext, so we get buffer_load_ushort instead of buffer_load_sshort.
23312559441SBjorn Pettersson; SI-PROMOTE: buffer_load_ushort v{{[0-9]+}}, v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}}
2348a028bf4SMatt Arsenaultdefine void @short_array(i32 addrspace(1)* %out, i32 %index) #0 {
23523dcd6e0SJan Veselyentry:
23623dcd6e0SJan Vesely  %0 = alloca [2 x i16]
23723dcd6e0SJan Vesely  %1 = getelementptr inbounds [2 x i16], [2 x i16]* %0, i32 0, i32 0
23823dcd6e0SJan Vesely  %2 = getelementptr inbounds [2 x i16], [2 x i16]* %0, i32 0, i32 1
23923dcd6e0SJan Vesely  store i16 0, i16* %1
24023dcd6e0SJan Vesely  store i16 1, i16* %2
24123dcd6e0SJan Vesely  %3 = getelementptr inbounds [2 x i16], [2 x i16]* %0, i32 0, i32 %index
24223dcd6e0SJan Vesely  %4 = load i16, i16* %3
24323dcd6e0SJan Vesely  %5 = sext i16 %4 to i32
24423dcd6e0SJan Vesely  store i32 %5, i32 addrspace(1)* %out
24523dcd6e0SJan Vesely  ret void
24623dcd6e0SJan Vesely}
24723dcd6e0SJan Vesely
24823dcd6e0SJan Vesely; FUNC-LABEL: {{^}}char_array:
24923dcd6e0SJan Vesely
25023dcd6e0SJan Vesely; R600: MOVA_INT
25123dcd6e0SJan Vesely
252*39787bdcSMatt Arsenault; SI-PROMOTE-DAG: buffer_store_byte v{{[0-9]+}}, off, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}} ; encoding:
253*39787bdcSMatt Arsenault; SI-PROMOTE-DAG: buffer_store_byte v{{[0-9]+}}, off, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}} offset:1 ; encoding:
254*39787bdcSMatt Arsenault
255*39787bdcSMatt Arsenault; SI-ALLOCA-DAG: buffer_store_byte v{{[0-9]+}}, v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}} offen ; encoding: [0x00,0x10,0x60,0xe0
256*39787bdcSMatt Arsenault; SI-ALLOCA-DAG: buffer_store_byte v{{[0-9]+}}, v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}} offen offset:1 ; encoding: [0x01,0x10,0x60,0xe0
2578a028bf4SMatt Arsenaultdefine void @char_array(i32 addrspace(1)* %out, i32 %index) #0 {
25823dcd6e0SJan Veselyentry:
25923dcd6e0SJan Vesely  %0 = alloca [2 x i8]
26023dcd6e0SJan Vesely  %1 = getelementptr inbounds [2 x i8], [2 x i8]* %0, i32 0, i32 0
26123dcd6e0SJan Vesely  %2 = getelementptr inbounds [2 x i8], [2 x i8]* %0, i32 0, i32 1
26223dcd6e0SJan Vesely  store i8 0, i8* %1
26323dcd6e0SJan Vesely  store i8 1, i8* %2
26423dcd6e0SJan Vesely  %3 = getelementptr inbounds [2 x i8], [2 x i8]* %0, i32 0, i32 %index
26523dcd6e0SJan Vesely  %4 = load i8, i8* %3
26623dcd6e0SJan Vesely  %5 = sext i8 %4 to i32
26723dcd6e0SJan Vesely  store i32 %5, i32 addrspace(1)* %out
26823dcd6e0SJan Vesely  ret void
26923dcd6e0SJan Vesely}
27023dcd6e0SJan Vesely
27123dcd6e0SJan Vesely; Test that two stack objects are not stored in the same register
27223dcd6e0SJan Vesely; The second stack object should be in T3.X
27323dcd6e0SJan Vesely; FUNC-LABEL: {{^}}no_overlap:
274*39787bdcSMatt Arsenault; R600-CHECK: MOV
275*39787bdcSMatt Arsenault; R600-CHECK: [[CHAN:[XYZW]]]+
27623dcd6e0SJan Vesely; R600-NOT: [[CHAN]]+
27723dcd6e0SJan Vesely; SI: v_mov_b32_e32 v3
2788a028bf4SMatt Arsenaultdefine void @no_overlap(i32 addrspace(1)* %out, i32 %in) #0 {
27923dcd6e0SJan Veselyentry:
28023dcd6e0SJan Vesely  %0 = alloca [3 x i8], align 1
28123dcd6e0SJan Vesely  %1 = alloca [2 x i8], align 1
28223dcd6e0SJan Vesely  %2 = getelementptr [3 x i8], [3 x i8]* %0, i32 0, i32 0
28323dcd6e0SJan Vesely  %3 = getelementptr [3 x i8], [3 x i8]* %0, i32 0, i32 1
28423dcd6e0SJan Vesely  %4 = getelementptr [3 x i8], [3 x i8]* %0, i32 0, i32 2
28523dcd6e0SJan Vesely  %5 = getelementptr [2 x i8], [2 x i8]* %1, i32 0, i32 0
28623dcd6e0SJan Vesely  %6 = getelementptr [2 x i8], [2 x i8]* %1, i32 0, i32 1
28723dcd6e0SJan Vesely  store i8 0, i8* %2
28823dcd6e0SJan Vesely  store i8 1, i8* %3
28923dcd6e0SJan Vesely  store i8 2, i8* %4
29023dcd6e0SJan Vesely  store i8 1, i8* %5
29123dcd6e0SJan Vesely  store i8 0, i8* %6
29223dcd6e0SJan Vesely  %7 = getelementptr [3 x i8], [3 x i8]* %0, i32 0, i32 %in
29323dcd6e0SJan Vesely  %8 = getelementptr [2 x i8], [2 x i8]* %1, i32 0, i32 %in
29423dcd6e0SJan Vesely  %9 = load i8, i8* %7
29523dcd6e0SJan Vesely  %10 = load i8, i8* %8
29623dcd6e0SJan Vesely  %11 = add i8 %9, %10
29723dcd6e0SJan Vesely  %12 = sext i8 %11 to i32
29823dcd6e0SJan Vesely  store i32 %12, i32 addrspace(1)* %out
29923dcd6e0SJan Vesely  ret void
30023dcd6e0SJan Vesely}
30123dcd6e0SJan Vesely
3028a028bf4SMatt Arsenaultdefine void @char_array_array(i32 addrspace(1)* %out, i32 %index) #0 {
30323dcd6e0SJan Veselyentry:
30423dcd6e0SJan Vesely  %alloca = alloca [2 x [2 x i8]]
30523dcd6e0SJan Vesely  %gep0 = getelementptr [2 x [2 x i8]], [2 x [2 x i8]]* %alloca, i32 0, i32 0, i32 0
30623dcd6e0SJan Vesely  %gep1 = getelementptr [2 x [2 x i8]], [2 x [2 x i8]]* %alloca, i32 0, i32 0, i32 1
30723dcd6e0SJan Vesely  store i8 0, i8* %gep0
30823dcd6e0SJan Vesely  store i8 1, i8* %gep1
30923dcd6e0SJan Vesely  %gep2 = getelementptr [2 x [2 x i8]], [2 x [2 x i8]]* %alloca, i32 0, i32 0, i32 %index
31023dcd6e0SJan Vesely  %load = load i8, i8* %gep2
31123dcd6e0SJan Vesely  %sext = sext i8 %load to i32
31223dcd6e0SJan Vesely  store i32 %sext, i32 addrspace(1)* %out
31323dcd6e0SJan Vesely  ret void
31423dcd6e0SJan Vesely}
31523dcd6e0SJan Vesely
3168a028bf4SMatt Arsenaultdefine void @i32_array_array(i32 addrspace(1)* %out, i32 %index) #0 {
31723dcd6e0SJan Veselyentry:
31823dcd6e0SJan Vesely  %alloca = alloca [2 x [2 x i32]]
31923dcd6e0SJan Vesely  %gep0 = getelementptr [2 x [2 x i32]], [2 x [2 x i32]]* %alloca, i32 0, i32 0, i32 0
32023dcd6e0SJan Vesely  %gep1 = getelementptr [2 x [2 x i32]], [2 x [2 x i32]]* %alloca, i32 0, i32 0, i32 1
32123dcd6e0SJan Vesely  store i32 0, i32* %gep0
32223dcd6e0SJan Vesely  store i32 1, i32* %gep1
32323dcd6e0SJan Vesely  %gep2 = getelementptr [2 x [2 x i32]], [2 x [2 x i32]]* %alloca, i32 0, i32 0, i32 %index
32423dcd6e0SJan Vesely  %load = load i32, i32* %gep2
32523dcd6e0SJan Vesely  store i32 %load, i32 addrspace(1)* %out
32623dcd6e0SJan Vesely  ret void
32723dcd6e0SJan Vesely}
32823dcd6e0SJan Vesely
3298a028bf4SMatt Arsenaultdefine void @i64_array_array(i64 addrspace(1)* %out, i32 %index) #0 {
33023dcd6e0SJan Veselyentry:
33123dcd6e0SJan Vesely  %alloca = alloca [2 x [2 x i64]]
33223dcd6e0SJan Vesely  %gep0 = getelementptr [2 x [2 x i64]], [2 x [2 x i64]]* %alloca, i32 0, i32 0, i32 0
33323dcd6e0SJan Vesely  %gep1 = getelementptr [2 x [2 x i64]], [2 x [2 x i64]]* %alloca, i32 0, i32 0, i32 1
33423dcd6e0SJan Vesely  store i64 0, i64* %gep0
33523dcd6e0SJan Vesely  store i64 1, i64* %gep1
33623dcd6e0SJan Vesely  %gep2 = getelementptr [2 x [2 x i64]], [2 x [2 x i64]]* %alloca, i32 0, i32 0, i32 %index
33723dcd6e0SJan Vesely  %load = load i64, i64* %gep2
33823dcd6e0SJan Vesely  store i64 %load, i64 addrspace(1)* %out
33923dcd6e0SJan Vesely  ret void
34023dcd6e0SJan Vesely}
34123dcd6e0SJan Vesely
34223dcd6e0SJan Vesely%struct.pair32 = type { i32, i32 }
34323dcd6e0SJan Vesely
3448a028bf4SMatt Arsenaultdefine void @struct_array_array(i32 addrspace(1)* %out, i32 %index) #0 {
34523dcd6e0SJan Veselyentry:
34623dcd6e0SJan Vesely  %alloca = alloca [2 x [2 x %struct.pair32]]
34723dcd6e0SJan Vesely  %gep0 = getelementptr [2 x [2 x %struct.pair32]], [2 x [2 x %struct.pair32]]* %alloca, i32 0, i32 0, i32 0, i32 1
34823dcd6e0SJan Vesely  %gep1 = getelementptr [2 x [2 x %struct.pair32]], [2 x [2 x %struct.pair32]]* %alloca, i32 0, i32 0, i32 1, i32 1
34923dcd6e0SJan Vesely  store i32 0, i32* %gep0
35023dcd6e0SJan Vesely  store i32 1, i32* %gep1
35123dcd6e0SJan Vesely  %gep2 = getelementptr [2 x [2 x %struct.pair32]], [2 x [2 x %struct.pair32]]* %alloca, i32 0, i32 0, i32 %index, i32 0
35223dcd6e0SJan Vesely  %load = load i32, i32* %gep2
35323dcd6e0SJan Vesely  store i32 %load, i32 addrspace(1)* %out
35423dcd6e0SJan Vesely  ret void
35523dcd6e0SJan Vesely}
35623dcd6e0SJan Vesely
3578a028bf4SMatt Arsenaultdefine void @struct_pair32_array(i32 addrspace(1)* %out, i32 %index) #0 {
35823dcd6e0SJan Veselyentry:
35923dcd6e0SJan Vesely  %alloca = alloca [2 x %struct.pair32]
36023dcd6e0SJan Vesely  %gep0 = getelementptr [2 x %struct.pair32], [2 x %struct.pair32]* %alloca, i32 0, i32 0, i32 1
36123dcd6e0SJan Vesely  %gep1 = getelementptr [2 x %struct.pair32], [2 x %struct.pair32]* %alloca, i32 0, i32 1, i32 0
36223dcd6e0SJan Vesely  store i32 0, i32* %gep0
36323dcd6e0SJan Vesely  store i32 1, i32* %gep1
36423dcd6e0SJan Vesely  %gep2 = getelementptr [2 x %struct.pair32], [2 x %struct.pair32]* %alloca, i32 0, i32 %index, i32 0
36523dcd6e0SJan Vesely  %load = load i32, i32* %gep2
36623dcd6e0SJan Vesely  store i32 %load, i32 addrspace(1)* %out
36723dcd6e0SJan Vesely  ret void
36823dcd6e0SJan Vesely}
36923dcd6e0SJan Vesely
37023dcd6e0SJan Veselydefine void @select_private(i32 addrspace(1)* %out, i32 %in) nounwind {
37123dcd6e0SJan Veselyentry:
37223dcd6e0SJan Vesely  %tmp = alloca [2 x i32]
37323dcd6e0SJan Vesely  %tmp1 = getelementptr [2 x i32], [2 x i32]* %tmp, i32 0, i32 0
37423dcd6e0SJan Vesely  %tmp2 = getelementptr [2 x i32], [2 x i32]* %tmp, i32 0, i32 1
37523dcd6e0SJan Vesely  store i32 0, i32* %tmp1
37623dcd6e0SJan Vesely  store i32 1, i32* %tmp2
37723dcd6e0SJan Vesely  %cmp = icmp eq i32 %in, 0
37823dcd6e0SJan Vesely  %sel = select i1 %cmp, i32* %tmp1, i32* %tmp2
37923dcd6e0SJan Vesely  %load = load i32, i32* %sel
38023dcd6e0SJan Vesely  store i32 %load, i32 addrspace(1)* %out
38123dcd6e0SJan Vesely  ret void
38223dcd6e0SJan Vesely}
38323dcd6e0SJan Vesely
38423dcd6e0SJan Vesely; AMDGPUPromoteAlloca does not know how to handle ptrtoint.  When it
38523dcd6e0SJan Vesely; finds one, it should stop trying to promote.
38623dcd6e0SJan Vesely
38723dcd6e0SJan Vesely; FUNC-LABEL: ptrtoint:
38823dcd6e0SJan Vesely; SI-NOT: ds_write
38923dcd6e0SJan Vesely; SI: buffer_store_dword v{{[0-9]+}}, v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}} offen
39023dcd6e0SJan Vesely; SI: buffer_load_dword v{{[0-9]+}}, v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}} offen offset:5 ;
3918a028bf4SMatt Arsenaultdefine void @ptrtoint(i32 addrspace(1)* %out, i32 %a, i32 %b) #0 {
39223dcd6e0SJan Vesely  %alloca = alloca [16 x i32]
39323dcd6e0SJan Vesely  %tmp0 = getelementptr [16 x i32], [16 x i32]* %alloca, i32 0, i32 %a
39423dcd6e0SJan Vesely  store i32 5, i32* %tmp0
39523dcd6e0SJan Vesely  %tmp1 = ptrtoint [16 x i32]* %alloca to i32
39623dcd6e0SJan Vesely  %tmp2 = add i32 %tmp1, 5
39723dcd6e0SJan Vesely  %tmp3 = inttoptr i32 %tmp2 to i32*
39823dcd6e0SJan Vesely  %tmp4 = getelementptr i32, i32* %tmp3, i32 %b
39923dcd6e0SJan Vesely  %tmp5 = load i32, i32* %tmp4
40023dcd6e0SJan Vesely  store i32 %tmp5, i32 addrspace(1)* %out
40123dcd6e0SJan Vesely  ret void
40223dcd6e0SJan Vesely}
40323dcd6e0SJan Vesely
404c438ef57SMatt Arsenault; OPT-LABEL: @pointer_typed_alloca(
405c438ef57SMatt Arsenault; OPT:  getelementptr inbounds [256 x i32 addrspace(1)*], [256 x i32 addrspace(1)*] addrspace(3)* @pointer_typed_alloca.A.addr, i32 0, i32 %{{[0-9]+}}
406c438ef57SMatt Arsenault; OPT: load i32 addrspace(1)*, i32 addrspace(1)* addrspace(3)* %{{[0-9]+}}, align 4
407c438ef57SMatt Arsenaultdefine void @pointer_typed_alloca(i32 addrspace(1)* %A) {
408c438ef57SMatt Arsenaultentry:
409c438ef57SMatt Arsenault  %A.addr = alloca i32 addrspace(1)*, align 4
410c438ef57SMatt Arsenault  store i32 addrspace(1)* %A, i32 addrspace(1)** %A.addr, align 4
411c438ef57SMatt Arsenault  %ld0 = load i32 addrspace(1)*, i32 addrspace(1)** %A.addr, align 4
412c438ef57SMatt Arsenault  %arrayidx = getelementptr inbounds i32, i32 addrspace(1)* %ld0, i32 0
413c438ef57SMatt Arsenault  store i32 1, i32 addrspace(1)* %arrayidx, align 4
414c438ef57SMatt Arsenault  %ld1 = load i32 addrspace(1)*, i32 addrspace(1)** %A.addr, align 4
415c438ef57SMatt Arsenault  %arrayidx1 = getelementptr inbounds i32, i32 addrspace(1)* %ld1, i32 1
416c438ef57SMatt Arsenault  store i32 2, i32 addrspace(1)* %arrayidx1, align 4
417c438ef57SMatt Arsenault  %ld2 = load i32 addrspace(1)*, i32 addrspace(1)** %A.addr, align 4
418c438ef57SMatt Arsenault  %arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %ld2, i32 2
419c438ef57SMatt Arsenault  store i32 3, i32 addrspace(1)* %arrayidx2, align 4
420c438ef57SMatt Arsenault  ret void
421c438ef57SMatt Arsenault}
422c438ef57SMatt Arsenault
423687ca8dfSJan Vesely; FUNC-LABEL: v16i32_stack:
424687ca8dfSJan Vesely
425687ca8dfSJan Vesely; R600: MOVA_INT
426687ca8dfSJan Vesely; R600: MOVA_INT
427687ca8dfSJan Vesely; R600: MOVA_INT
428687ca8dfSJan Vesely; R600: MOVA_INT
429687ca8dfSJan Vesely; R600: MOVA_INT
430687ca8dfSJan Vesely; R600: MOVA_INT
431687ca8dfSJan Vesely; R600: MOVA_INT
432687ca8dfSJan Vesely; R600: MOVA_INT
433687ca8dfSJan Vesely; R600: MOVA_INT
434687ca8dfSJan Vesely; R600: MOVA_INT
435687ca8dfSJan Vesely; R600: MOVA_INT
436687ca8dfSJan Vesely; R600: MOVA_INT
437687ca8dfSJan Vesely; R600: MOVA_INT
438687ca8dfSJan Vesely; R600: MOVA_INT
439687ca8dfSJan Vesely; R600: MOVA_INT
440687ca8dfSJan Vesely; R600: MOVA_INT
441687ca8dfSJan Vesely
442687ca8dfSJan Vesely; SI: buffer_load_dword
443687ca8dfSJan Vesely; SI: buffer_load_dword
444687ca8dfSJan Vesely; SI: buffer_load_dword
445687ca8dfSJan Vesely; SI: buffer_load_dword
446687ca8dfSJan Vesely; SI: buffer_load_dword
447687ca8dfSJan Vesely; SI: buffer_load_dword
448687ca8dfSJan Vesely; SI: buffer_load_dword
449687ca8dfSJan Vesely; SI: buffer_load_dword
450687ca8dfSJan Vesely; SI: buffer_load_dword
451687ca8dfSJan Vesely; SI: buffer_load_dword
452687ca8dfSJan Vesely; SI: buffer_load_dword
453687ca8dfSJan Vesely; SI: buffer_load_dword
454687ca8dfSJan Vesely; SI: buffer_load_dword
455687ca8dfSJan Vesely; SI: buffer_load_dword
456687ca8dfSJan Vesely; SI: buffer_load_dword
457687ca8dfSJan Vesely; SI: buffer_load_dword
458687ca8dfSJan Vesely
459687ca8dfSJan Veselydefine void @v16i32_stack(<16 x i32> addrspace(1)* %out, i32 %a) {
460687ca8dfSJan Vesely  %alloca = alloca [2 x <16 x i32>]
461687ca8dfSJan Vesely  %tmp0 = getelementptr [2 x <16 x i32>], [2 x <16 x i32>]* %alloca, i32 0, i32 %a
462687ca8dfSJan Vesely  %tmp5 = load <16 x i32>, <16 x i32>* %tmp0
463687ca8dfSJan Vesely  store <16 x i32> %tmp5, <16 x i32> addrspace(1)* %out
464687ca8dfSJan Vesely  ret void
465687ca8dfSJan Vesely}
466687ca8dfSJan Vesely
467687ca8dfSJan Vesely; FUNC-LABEL: v16float_stack:
468687ca8dfSJan Vesely
469687ca8dfSJan Vesely; R600: MOVA_INT
470687ca8dfSJan Vesely; R600: MOVA_INT
471687ca8dfSJan Vesely; R600: MOVA_INT
472687ca8dfSJan Vesely; R600: MOVA_INT
473687ca8dfSJan Vesely; R600: MOVA_INT
474687ca8dfSJan Vesely; R600: MOVA_INT
475687ca8dfSJan Vesely; R600: MOVA_INT
476687ca8dfSJan Vesely; R600: MOVA_INT
477687ca8dfSJan Vesely; R600: MOVA_INT
478687ca8dfSJan Vesely; R600: MOVA_INT
479687ca8dfSJan Vesely; R600: MOVA_INT
480687ca8dfSJan Vesely; R600: MOVA_INT
481687ca8dfSJan Vesely; R600: MOVA_INT
482687ca8dfSJan Vesely; R600: MOVA_INT
483687ca8dfSJan Vesely; R600: MOVA_INT
484687ca8dfSJan Vesely; R600: MOVA_INT
485687ca8dfSJan Vesely
486687ca8dfSJan Vesely; SI: buffer_load_dword
487687ca8dfSJan Vesely; SI: buffer_load_dword
488687ca8dfSJan Vesely; SI: buffer_load_dword
489687ca8dfSJan Vesely; SI: buffer_load_dword
490687ca8dfSJan Vesely; SI: buffer_load_dword
491687ca8dfSJan Vesely; SI: buffer_load_dword
492687ca8dfSJan Vesely; SI: buffer_load_dword
493687ca8dfSJan Vesely; SI: buffer_load_dword
494687ca8dfSJan Vesely; SI: buffer_load_dword
495687ca8dfSJan Vesely; SI: buffer_load_dword
496687ca8dfSJan Vesely; SI: buffer_load_dword
497687ca8dfSJan Vesely; SI: buffer_load_dword
498687ca8dfSJan Vesely; SI: buffer_load_dword
499687ca8dfSJan Vesely; SI: buffer_load_dword
500687ca8dfSJan Vesely; SI: buffer_load_dword
501687ca8dfSJan Vesely; SI: buffer_load_dword
502687ca8dfSJan Vesely
503687ca8dfSJan Veselydefine void @v16float_stack(<16 x float> addrspace(1)* %out, i32 %a) {
504687ca8dfSJan Vesely  %alloca = alloca [2 x <16 x float>]
505687ca8dfSJan Vesely  %tmp0 = getelementptr [2 x <16 x float>], [2 x <16 x float>]* %alloca, i32 0, i32 %a
506687ca8dfSJan Vesely  %tmp5 = load <16 x float>, <16 x float>* %tmp0
507687ca8dfSJan Vesely  store <16 x float> %tmp5, <16 x float> addrspace(1)* %out
508687ca8dfSJan Vesely  ret void
509687ca8dfSJan Vesely}
510687ca8dfSJan Vesely
511687ca8dfSJan Vesely; FUNC-LABEL: v2float_stack:
512687ca8dfSJan Vesely
513687ca8dfSJan Vesely; R600: MOVA_INT
514687ca8dfSJan Vesely; R600: MOVA_INT
515687ca8dfSJan Vesely
516687ca8dfSJan Vesely; SI: buffer_load_dword
517687ca8dfSJan Vesely; SI: buffer_load_dword
518687ca8dfSJan Vesely
519687ca8dfSJan Veselydefine void @v2float_stack(<2 x float> addrspace(1)* %out, i32 %a) {
520687ca8dfSJan Vesely  %alloca = alloca [16 x <2 x float>]
521687ca8dfSJan Vesely  %tmp0 = getelementptr [16 x <2 x float>], [16 x <2 x float>]* %alloca, i32 0, i32 %a
522687ca8dfSJan Vesely  %tmp5 = load <2 x float>, <2 x float>* %tmp0
523687ca8dfSJan Vesely  store <2 x float> %tmp5, <2 x float> addrspace(1)* %out
524687ca8dfSJan Vesely  ret void
525687ca8dfSJan Vesely}
526687ca8dfSJan Vesely
527efb24540SMatt Arsenault; OPT-LABEL: @direct_alloca_read_0xi32(
528efb24540SMatt Arsenault; OPT: store [0 x i32] undef, [0 x i32] addrspace(3)*
529efb24540SMatt Arsenault; OPT: load [0 x i32], [0 x i32] addrspace(3)*
530efb24540SMatt Arsenaultdefine void @direct_alloca_read_0xi32([0 x i32] addrspace(1)* %out, i32 %index) {
531efb24540SMatt Arsenaultentry:
532efb24540SMatt Arsenault  %tmp = alloca [0 x i32]
533efb24540SMatt Arsenault  store [0 x i32] [], [0 x i32]* %tmp
534efb24540SMatt Arsenault  %load = load [0 x i32], [0 x i32]* %tmp
535efb24540SMatt Arsenault  store [0 x i32] %load, [0 x i32] addrspace(1)* %out
536efb24540SMatt Arsenault  ret void
537efb24540SMatt Arsenault}
538efb24540SMatt Arsenault
539efb24540SMatt Arsenault; OPT-LABEL: @direct_alloca_read_1xi32(
540efb24540SMatt Arsenault; OPT: store [1 x i32] zeroinitializer, [1 x i32] addrspace(3)*
541efb24540SMatt Arsenault; OPT: load [1 x i32], [1 x i32] addrspace(3)*
542efb24540SMatt Arsenaultdefine void @direct_alloca_read_1xi32([1 x i32] addrspace(1)* %out, i32 %index) {
543efb24540SMatt Arsenaultentry:
544efb24540SMatt Arsenault  %tmp = alloca [1 x i32]
545efb24540SMatt Arsenault  store [1 x i32] [i32 0], [1 x i32]* %tmp
546efb24540SMatt Arsenault  %load = load [1 x i32], [1 x i32]* %tmp
547efb24540SMatt Arsenault  store [1 x i32] %load, [1 x i32] addrspace(1)* %out
548efb24540SMatt Arsenault  ret void
549efb24540SMatt Arsenault}
550efb24540SMatt Arsenault
5511d65026cSKonstantin Zhuravlyovattributes #0 = { nounwind "amdgpu-waves-per-eu"="1,2" }
552efb24540SMatt Arsenault
553efb24540SMatt Arsenault; HSAOPT: !0 = !{}
554efb24540SMatt Arsenault; HSAOPT: !1 = !{i32 0, i32 2048}
555efb24540SMatt Arsenault
556efb24540SMatt Arsenault; NOHSAOPT: !0 = !{i32 0, i32 2048}
557