123dcd6e0SJan Vesely; RUN: llc -march=r600 -mcpu=cypress < %s | FileCheck %s -check-prefix=R600 -check-prefix=FUNC 223dcd6e0SJan Vesely; RUN: llc -show-mc-encoding -mattr=+promote-alloca -verify-machineinstrs -march=amdgcn < %s | FileCheck %s -check-prefix=SI-PROMOTE -check-prefix=SI -check-prefix=FUNC 323dcd6e0SJan Vesely; RUN: llc -show-mc-encoding -mattr=+promote-alloca -verify-machineinstrs -mtriple=amdgcn--amdhsa -mcpu=kaveri < %s | FileCheck %s -check-prefix=SI-PROMOTE -check-prefix=SI -check-prefix=FUNC -check-prefix=HSA-PROMOTE 423dcd6e0SJan Vesely; RUN: llc -show-mc-encoding -mattr=-promote-alloca -verify-machineinstrs -march=amdgcn < %s | FileCheck %s -check-prefix=SI-ALLOCA -check-prefix=SI -check-prefix=FUNC 523dcd6e0SJan Vesely; RUN: llc -show-mc-encoding -mattr=-promote-alloca -verify-machineinstrs -mtriple=amdgcn-amdhsa -mcpu=kaveri < %s | FileCheck %s -check-prefix=SI-ALLOCA -check-prefix=SI -check-prefix=FUNC -check-prefix=HSA-ALLOCA 623dcd6e0SJan Vesely; RUN: llc -show-mc-encoding -mattr=+promote-alloca -verify-machineinstrs -march=amdgcn -mcpu=tonga < %s | FileCheck %s -check-prefix=SI-PROMOTE -check-prefix=SI -check-prefix=FUNC 723dcd6e0SJan Vesely; RUN: llc -show-mc-encoding -mattr=-promote-alloca -verify-machineinstrs -march=amdgcn -mcpu=tonga < %s | FileCheck %s -check-prefix=SI-ALLOCA -check-prefix=SI -check-prefix=FUNC 823dcd6e0SJan Vesely 923dcd6e0SJan Vesely; RUN: opt -S -mtriple=amdgcn-unknown-amdhsa -mcpu=kaveri -amdgpu-promote-alloca < %s | FileCheck -check-prefix=HSAOPT -check-prefix=OPT %s 1023dcd6e0SJan Vesely; RUN: opt -S -mtriple=amdgcn-unknown-unknown -mcpu=kaveri -amdgpu-promote-alloca < %s | FileCheck -check-prefix=NOHSAOPT -check-prefix=OPT %s 1123dcd6e0SJan Vesely 1223dcd6e0SJan Vesely; HSAOPT: @mova_same_clause.stack = internal unnamed_addr addrspace(3) global [256 x [5 x i32]] undef, align 4 1323dcd6e0SJan Vesely; HSAOPT: @high_alignment.stack = internal unnamed_addr addrspace(3) global [256 x [8 x i32]] undef, align 16 1423dcd6e0SJan Vesely 1523dcd6e0SJan Vesely 1623dcd6e0SJan Vesely; FUNC-LABEL: {{^}}mova_same_clause: 1723dcd6e0SJan Vesely; OPT-LABEL: @mova_same_clause( 1823dcd6e0SJan Vesely 1923dcd6e0SJan Vesely; R600: LDS_WRITE 2023dcd6e0SJan Vesely; R600: LDS_WRITE 2123dcd6e0SJan Vesely; R600: LDS_READ 2223dcd6e0SJan Vesely; R600: LDS_READ 2323dcd6e0SJan Vesely 2423dcd6e0SJan Vesely; HSA-PROMOTE: .amd_kernel_code_t 2523dcd6e0SJan Vesely; HSA-PROMOTE: workgroup_group_segment_byte_size = 5120 2623dcd6e0SJan Vesely; HSA-PROMOTE: .end_amd_kernel_code_t 2723dcd6e0SJan Vesely 2823dcd6e0SJan Vesely; FIXME: These should be merged 2923dcd6e0SJan Vesely; HSA-PROMOTE: s_load_dword s{{[0-9]+}}, s[4:5], 0x1 3023dcd6e0SJan Vesely; HSA-PROMOTE: s_load_dword s{{[0-9]+}}, s[4:5], 0x2 3123dcd6e0SJan Vesely 3223dcd6e0SJan Vesely; SI-PROMOTE: ds_write_b32 3323dcd6e0SJan Vesely; SI-PROMOTE: ds_write_b32 3423dcd6e0SJan Vesely; SI-PROMOTE: ds_read_b32 3523dcd6e0SJan Vesely; SI-PROMOTE: ds_read_b32 3623dcd6e0SJan Vesely 3723dcd6e0SJan Vesely; HSA-ALLOCA: .amd_kernel_code_t 3823dcd6e0SJan Vesely; FIXME: Creating the emergency stack slots causes us to over-estimate scratch 3923dcd6e0SJan Vesely; by 4 bytes. 4023dcd6e0SJan Vesely; HSA-ALLOCA: workitem_private_segment_byte_size = 24 4123dcd6e0SJan Vesely; HSA-ALLOCA: .end_amd_kernel_code_t 4223dcd6e0SJan Vesely 4323dcd6e0SJan Vesely; HSA-ALLOCA: s_mov_b32 flat_scratch_lo, s7 4423dcd6e0SJan Vesely; HSA-ALLOCA: s_add_u32 s6, s6, s9 4523dcd6e0SJan Vesely; HSA-ALLOCA: s_lshr_b32 flat_scratch_hi, s6, 8 4623dcd6e0SJan Vesely 4723dcd6e0SJan 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 4823dcd6e0SJan 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 4923dcd6e0SJan Vesely 5023dcd6e0SJan Vesely 5123dcd6e0SJan Vesely; HSAOPT: [[DISPATCH_PTR:%[0-9]+]] = call noalias nonnull dereferenceable(64) i8 addrspace(2)* @llvm.amdgcn.dispatch.ptr() 5223dcd6e0SJan Vesely; HSAOPT: [[CAST_DISPATCH_PTR:%[0-9]+]] = bitcast i8 addrspace(2)* [[DISPATCH_PTR]] to i32 addrspace(2)* 5323dcd6e0SJan Vesely; HSAOPT: [[GEP0:%[0-9]+]] = getelementptr inbounds i32, i32 addrspace(2)* [[CAST_DISPATCH_PTR]], i64 1 5423dcd6e0SJan Vesely; HSAOPT: [[LDXY:%[0-9]+]] = load i32, i32 addrspace(2)* [[GEP0]], align 4, !invariant.load !0 5523dcd6e0SJan Vesely; HSAOPT: [[GEP1:%[0-9]+]] = getelementptr inbounds i32, i32 addrspace(2)* [[CAST_DISPATCH_PTR]], i64 2 5623dcd6e0SJan Vesely; HSAOPT: [[LDZU:%[0-9]+]] = load i32, i32 addrspace(2)* [[GEP1]], align 4, !range !1, !invariant.load !0 5723dcd6e0SJan Vesely; HSAOPT: [[EXTRACTY:%[0-9]+]] = lshr i32 [[LDXY]], 16 5823dcd6e0SJan Vesely 5923dcd6e0SJan Vesely; HSAOPT: [[WORKITEM_ID_X:%[0-9]+]] = call i32 @llvm.amdgcn.workitem.id.x(), !range !1 6023dcd6e0SJan Vesely; HSAOPT: [[WORKITEM_ID_Y:%[0-9]+]] = call i32 @llvm.amdgcn.workitem.id.y(), !range !1 6123dcd6e0SJan Vesely; HSAOPT: [[WORKITEM_ID_Z:%[0-9]+]] = call i32 @llvm.amdgcn.workitem.id.z(), !range !1 6223dcd6e0SJan Vesely 6323dcd6e0SJan Vesely; HSAOPT: [[Y_SIZE_X_Z_SIZE:%[0-9]+]] = mul nuw nsw i32 [[EXTRACTY]], [[LDZU]] 6423dcd6e0SJan Vesely; HSAOPT: [[YZ_X_XID:%[0-9]+]] = mul i32 [[Y_SIZE_X_Z_SIZE]], [[WORKITEM_ID_X]] 6523dcd6e0SJan Vesely; HSAOPT: [[Y_X_Z_SIZE:%[0-9]+]] = mul nuw nsw i32 [[WORKITEM_ID_Y]], [[LDZU]] 6623dcd6e0SJan Vesely; HSAOPT: [[ADD_YZ_X_X_YZ_SIZE:%[0-9]+]] = add i32 [[YZ_X_XID]], [[Y_X_Z_SIZE]] 6723dcd6e0SJan Vesely; HSAOPT: [[ADD_ZID:%[0-9]+]] = add i32 [[ADD_YZ_X_X_YZ_SIZE]], [[WORKITEM_ID_Z]] 6823dcd6e0SJan Vesely 6923dcd6e0SJan 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]] 7023dcd6e0SJan Vesely; HSAOPT: %arrayidx1 = getelementptr inbounds [5 x i32], [5 x i32] addrspace(3)* [[LOCAL_GEP]], i32 0, i32 {{%[0-9]+}} 7123dcd6e0SJan Vesely; HSAOPT: %arrayidx3 = getelementptr inbounds [5 x i32], [5 x i32] addrspace(3)* [[LOCAL_GEP]], i32 0, i32 {{%[0-9]+}} 7223dcd6e0SJan Vesely; HSAOPT: %arrayidx10 = getelementptr inbounds [5 x i32], [5 x i32] addrspace(3)* [[LOCAL_GEP]], i32 0, i32 0 7323dcd6e0SJan Vesely; HSAOPT: %arrayidx12 = getelementptr inbounds [5 x i32], [5 x i32] addrspace(3)* [[LOCAL_GEP]], i32 0, i32 1 7423dcd6e0SJan Vesely 7523dcd6e0SJan Vesely 7623dcd6e0SJan Vesely; NOHSAOPT: call i32 @llvm.r600.read.local.size.y(), !range !0 7723dcd6e0SJan Vesely; NOHSAOPT: call i32 @llvm.r600.read.local.size.z(), !range !0 7823dcd6e0SJan Vesely; NOHSAOPT: call i32 @llvm.amdgcn.workitem.id.x(), !range !0 7923dcd6e0SJan Vesely; NOHSAOPT: call i32 @llvm.amdgcn.workitem.id.y(), !range !0 8023dcd6e0SJan Vesely; NOHSAOPT: call i32 @llvm.amdgcn.workitem.id.z(), !range !0 818a028bf4SMatt Arsenaultdefine void @mova_same_clause(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) #0 { 8223dcd6e0SJan Veselyentry: 8323dcd6e0SJan Vesely %stack = alloca [5 x i32], align 4 8423dcd6e0SJan Vesely %0 = load i32, i32 addrspace(1)* %in, align 4 8523dcd6e0SJan Vesely %arrayidx1 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %0 8623dcd6e0SJan Vesely store i32 4, i32* %arrayidx1, align 4 8723dcd6e0SJan Vesely %arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %in, i32 1 8823dcd6e0SJan Vesely %1 = load i32, i32 addrspace(1)* %arrayidx2, align 4 8923dcd6e0SJan Vesely %arrayidx3 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %1 9023dcd6e0SJan Vesely store i32 5, i32* %arrayidx3, align 4 9123dcd6e0SJan Vesely %arrayidx10 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 0 9223dcd6e0SJan Vesely %2 = load i32, i32* %arrayidx10, align 4 9323dcd6e0SJan Vesely store i32 %2, i32 addrspace(1)* %out, align 4 9423dcd6e0SJan Vesely %arrayidx12 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 1 9523dcd6e0SJan Vesely %3 = load i32, i32* %arrayidx12 9623dcd6e0SJan Vesely %arrayidx13 = getelementptr inbounds i32, i32 addrspace(1)* %out, i32 1 9723dcd6e0SJan Vesely store i32 %3, i32 addrspace(1)* %arrayidx13 9823dcd6e0SJan Vesely ret void 9923dcd6e0SJan Vesely} 10023dcd6e0SJan Vesely 10123dcd6e0SJan Vesely; OPT-LABEL: @high_alignment( 10223dcd6e0SJan Vesely; OPT: getelementptr inbounds [256 x [8 x i32]], [256 x [8 x i32]] addrspace(3)* @high_alignment.stack, i32 0, i32 %{{[0-9]+}} 1038a028bf4SMatt Arsenaultdefine void @high_alignment(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) #0 { 10423dcd6e0SJan Veselyentry: 10523dcd6e0SJan Vesely %stack = alloca [8 x i32], align 16 10623dcd6e0SJan Vesely %0 = load i32, i32 addrspace(1)* %in, align 4 10723dcd6e0SJan Vesely %arrayidx1 = getelementptr inbounds [8 x i32], [8 x i32]* %stack, i32 0, i32 %0 10823dcd6e0SJan Vesely store i32 4, i32* %arrayidx1, align 4 10923dcd6e0SJan Vesely %arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %in, i32 1 11023dcd6e0SJan Vesely %1 = load i32, i32 addrspace(1)* %arrayidx2, align 4 11123dcd6e0SJan Vesely %arrayidx3 = getelementptr inbounds [8 x i32], [8 x i32]* %stack, i32 0, i32 %1 11223dcd6e0SJan Vesely store i32 5, i32* %arrayidx3, align 4 11323dcd6e0SJan Vesely %arrayidx10 = getelementptr inbounds [8 x i32], [8 x i32]* %stack, i32 0, i32 0 11423dcd6e0SJan Vesely %2 = load i32, i32* %arrayidx10, align 4 11523dcd6e0SJan Vesely store i32 %2, i32 addrspace(1)* %out, align 4 11623dcd6e0SJan Vesely %arrayidx12 = getelementptr inbounds [8 x i32], [8 x i32]* %stack, i32 0, i32 1 11723dcd6e0SJan Vesely %3 = load i32, i32* %arrayidx12 11823dcd6e0SJan Vesely %arrayidx13 = getelementptr inbounds i32, i32 addrspace(1)* %out, i32 1 11923dcd6e0SJan Vesely store i32 %3, i32 addrspace(1)* %arrayidx13 12023dcd6e0SJan Vesely ret void 12123dcd6e0SJan Vesely} 12223dcd6e0SJan Vesely 12323dcd6e0SJan Vesely; FUNC-LABEL: {{^}}no_replace_inbounds_gep: 12423dcd6e0SJan Vesely; OPT-LABEL: @no_replace_inbounds_gep( 12523dcd6e0SJan Vesely; OPT: alloca [5 x i32] 12623dcd6e0SJan Vesely 12723dcd6e0SJan Vesely; SI-NOT: ds_write 1288a028bf4SMatt Arsenaultdefine void @no_replace_inbounds_gep(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) #0 { 12923dcd6e0SJan Veselyentry: 13023dcd6e0SJan Vesely %stack = alloca [5 x i32], align 4 13123dcd6e0SJan Vesely %0 = load i32, i32 addrspace(1)* %in, align 4 13223dcd6e0SJan Vesely %arrayidx1 = getelementptr [5 x i32], [5 x i32]* %stack, i32 0, i32 %0 13323dcd6e0SJan Vesely store i32 4, i32* %arrayidx1, align 4 13423dcd6e0SJan Vesely %arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %in, i32 1 13523dcd6e0SJan Vesely %1 = load i32, i32 addrspace(1)* %arrayidx2, align 4 13623dcd6e0SJan Vesely %arrayidx3 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %1 13723dcd6e0SJan Vesely store i32 5, i32* %arrayidx3, align 4 13823dcd6e0SJan Vesely %arrayidx10 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 0 13923dcd6e0SJan Vesely %2 = load i32, i32* %arrayidx10, align 4 14023dcd6e0SJan Vesely store i32 %2, i32 addrspace(1)* %out, align 4 14123dcd6e0SJan Vesely %arrayidx12 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 1 14223dcd6e0SJan Vesely %3 = load i32, i32* %arrayidx12 14323dcd6e0SJan Vesely %arrayidx13 = getelementptr inbounds i32, i32 addrspace(1)* %out, i32 1 14423dcd6e0SJan Vesely store i32 %3, i32 addrspace(1)* %arrayidx13 14523dcd6e0SJan Vesely ret void 14623dcd6e0SJan Vesely} 14723dcd6e0SJan Vesely 14823dcd6e0SJan Vesely; This test checks that the stack offset is calculated correctly for structs. 14923dcd6e0SJan Vesely; All register loads/stores should be optimized away, so there shouldn't be 15023dcd6e0SJan Vesely; any MOVA instructions. 15123dcd6e0SJan Vesely; 15223dcd6e0SJan Vesely; XXX: This generated code has unnecessary MOVs, we should be able to optimize 15323dcd6e0SJan Vesely; this. 15423dcd6e0SJan Vesely 15523dcd6e0SJan Vesely; FUNC-LABEL: {{^}}multiple_structs: 15623dcd6e0SJan Vesely; OPT-LABEL: @multiple_structs( 15723dcd6e0SJan Vesely 15823dcd6e0SJan Vesely; R600-NOT: MOVA_INT 15923dcd6e0SJan Vesely; SI-NOT: v_movrel 16023dcd6e0SJan Vesely; SI-NOT: v_movrel 16123dcd6e0SJan Vesely%struct.point = type { i32, i32 } 16223dcd6e0SJan Vesely 1638a028bf4SMatt Arsenaultdefine void @multiple_structs(i32 addrspace(1)* %out) #0 { 16423dcd6e0SJan Veselyentry: 16523dcd6e0SJan Vesely %a = alloca %struct.point 16623dcd6e0SJan Vesely %b = alloca %struct.point 16723dcd6e0SJan Vesely %a.x.ptr = getelementptr %struct.point, %struct.point* %a, i32 0, i32 0 16823dcd6e0SJan Vesely %a.y.ptr = getelementptr %struct.point, %struct.point* %a, i32 0, i32 1 16923dcd6e0SJan Vesely %b.x.ptr = getelementptr %struct.point, %struct.point* %b, i32 0, i32 0 17023dcd6e0SJan Vesely %b.y.ptr = getelementptr %struct.point, %struct.point* %b, i32 0, i32 1 17123dcd6e0SJan Vesely store i32 0, i32* %a.x.ptr 17223dcd6e0SJan Vesely store i32 1, i32* %a.y.ptr 17323dcd6e0SJan Vesely store i32 2, i32* %b.x.ptr 17423dcd6e0SJan Vesely store i32 3, i32* %b.y.ptr 17523dcd6e0SJan Vesely %a.indirect.ptr = getelementptr %struct.point, %struct.point* %a, i32 0, i32 0 17623dcd6e0SJan Vesely %b.indirect.ptr = getelementptr %struct.point, %struct.point* %b, i32 0, i32 0 17723dcd6e0SJan Vesely %a.indirect = load i32, i32* %a.indirect.ptr 17823dcd6e0SJan Vesely %b.indirect = load i32, i32* %b.indirect.ptr 17923dcd6e0SJan Vesely %0 = add i32 %a.indirect, %b.indirect 18023dcd6e0SJan Vesely store i32 %0, i32 addrspace(1)* %out 18123dcd6e0SJan Vesely ret void 18223dcd6e0SJan Vesely} 18323dcd6e0SJan Vesely 18423dcd6e0SJan Vesely; Test direct access of a private array inside a loop. The private array 18523dcd6e0SJan Vesely; loads and stores should be lowered to copies, so there shouldn't be any 18623dcd6e0SJan Vesely; MOVA instructions. 18723dcd6e0SJan Vesely 18823dcd6e0SJan Vesely; FUNC-LABEL: {{^}}direct_loop: 18923dcd6e0SJan Vesely; R600-NOT: MOVA_INT 19023dcd6e0SJan Vesely; SI-NOT: v_movrel 19123dcd6e0SJan Vesely 1928a028bf4SMatt Arsenaultdefine void @direct_loop(i32 addrspace(1)* %out, i32 addrspace(1)* %in) #0 { 19323dcd6e0SJan Veselyentry: 19423dcd6e0SJan Vesely %prv_array_const = alloca [2 x i32] 19523dcd6e0SJan Vesely %prv_array = alloca [2 x i32] 19623dcd6e0SJan Vesely %a = load i32, i32 addrspace(1)* %in 19723dcd6e0SJan Vesely %b_src_ptr = getelementptr inbounds i32, i32 addrspace(1)* %in, i32 1 19823dcd6e0SJan Vesely %b = load i32, i32 addrspace(1)* %b_src_ptr 19923dcd6e0SJan Vesely %a_dst_ptr = getelementptr inbounds [2 x i32], [2 x i32]* %prv_array_const, i32 0, i32 0 20023dcd6e0SJan Vesely store i32 %a, i32* %a_dst_ptr 20123dcd6e0SJan Vesely %b_dst_ptr = getelementptr inbounds [2 x i32], [2 x i32]* %prv_array_const, i32 0, i32 1 20223dcd6e0SJan Vesely store i32 %b, i32* %b_dst_ptr 20323dcd6e0SJan Vesely br label %for.body 20423dcd6e0SJan Vesely 20523dcd6e0SJan Veselyfor.body: 20623dcd6e0SJan Vesely %inc = phi i32 [0, %entry], [%count, %for.body] 20723dcd6e0SJan Vesely %x_ptr = getelementptr inbounds [2 x i32], [2 x i32]* %prv_array_const, i32 0, i32 0 20823dcd6e0SJan Vesely %x = load i32, i32* %x_ptr 20923dcd6e0SJan Vesely %y_ptr = getelementptr inbounds [2 x i32], [2 x i32]* %prv_array, i32 0, i32 0 21023dcd6e0SJan Vesely %y = load i32, i32* %y_ptr 21123dcd6e0SJan Vesely %xy = add i32 %x, %y 21223dcd6e0SJan Vesely store i32 %xy, i32* %y_ptr 21323dcd6e0SJan Vesely %count = add i32 %inc, 1 21423dcd6e0SJan Vesely %done = icmp eq i32 %count, 4095 21523dcd6e0SJan Vesely br i1 %done, label %for.end, label %for.body 21623dcd6e0SJan Vesely 21723dcd6e0SJan Veselyfor.end: 21823dcd6e0SJan Vesely %value_ptr = getelementptr inbounds [2 x i32], [2 x i32]* %prv_array, i32 0, i32 0 21923dcd6e0SJan Vesely %value = load i32, i32* %value_ptr 22023dcd6e0SJan Vesely store i32 %value, i32 addrspace(1)* %out 22123dcd6e0SJan Vesely ret void 22223dcd6e0SJan Vesely} 22323dcd6e0SJan Vesely 22423dcd6e0SJan Vesely; FUNC-LABEL: {{^}}short_array: 22523dcd6e0SJan Vesely 22623dcd6e0SJan Vesely; R600: MOVA_INT 22723dcd6e0SJan Vesely 22823dcd6e0SJan Vesely; SI-PROMOTE-DAG: buffer_store_short v{{[0-9]+}}, v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}} offen ; encoding: [0x00,0x10,0x68,0xe0 22923dcd6e0SJan Vesely; SI-PROMOTE-DAG: buffer_store_short v{{[0-9]+}}, v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}} offen offset:2 ; encoding: [0x02,0x10,0x68,0xe0 23023dcd6e0SJan Vesely; SI-PROMOTE: buffer_load_sshort v{{[0-9]+}}, v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}} 2318a028bf4SMatt Arsenaultdefine void @short_array(i32 addrspace(1)* %out, i32 %index) #0 { 23223dcd6e0SJan Veselyentry: 23323dcd6e0SJan Vesely %0 = alloca [2 x i16] 23423dcd6e0SJan Vesely %1 = getelementptr inbounds [2 x i16], [2 x i16]* %0, i32 0, i32 0 23523dcd6e0SJan Vesely %2 = getelementptr inbounds [2 x i16], [2 x i16]* %0, i32 0, i32 1 23623dcd6e0SJan Vesely store i16 0, i16* %1 23723dcd6e0SJan Vesely store i16 1, i16* %2 23823dcd6e0SJan Vesely %3 = getelementptr inbounds [2 x i16], [2 x i16]* %0, i32 0, i32 %index 23923dcd6e0SJan Vesely %4 = load i16, i16* %3 24023dcd6e0SJan Vesely %5 = sext i16 %4 to i32 24123dcd6e0SJan Vesely store i32 %5, i32 addrspace(1)* %out 24223dcd6e0SJan Vesely ret void 24323dcd6e0SJan Vesely} 24423dcd6e0SJan Vesely 24523dcd6e0SJan Vesely; FUNC-LABEL: {{^}}char_array: 24623dcd6e0SJan Vesely 24723dcd6e0SJan Vesely; R600: MOVA_INT 24823dcd6e0SJan Vesely 24923dcd6e0SJan Vesely; SI-DAG: buffer_store_byte v{{[0-9]+}}, v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}} offen ; encoding: [0x00,0x10,0x60,0xe0 25023dcd6e0SJan Vesely; SI-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 2518a028bf4SMatt Arsenaultdefine void @char_array(i32 addrspace(1)* %out, i32 %index) #0 { 25223dcd6e0SJan Veselyentry: 25323dcd6e0SJan Vesely %0 = alloca [2 x i8] 25423dcd6e0SJan Vesely %1 = getelementptr inbounds [2 x i8], [2 x i8]* %0, i32 0, i32 0 25523dcd6e0SJan Vesely %2 = getelementptr inbounds [2 x i8], [2 x i8]* %0, i32 0, i32 1 25623dcd6e0SJan Vesely store i8 0, i8* %1 25723dcd6e0SJan Vesely store i8 1, i8* %2 25823dcd6e0SJan Vesely %3 = getelementptr inbounds [2 x i8], [2 x i8]* %0, i32 0, i32 %index 25923dcd6e0SJan Vesely %4 = load i8, i8* %3 26023dcd6e0SJan Vesely %5 = sext i8 %4 to i32 26123dcd6e0SJan Vesely store i32 %5, i32 addrspace(1)* %out 26223dcd6e0SJan Vesely ret void 26323dcd6e0SJan Vesely 26423dcd6e0SJan Vesely} 26523dcd6e0SJan Vesely 26623dcd6e0SJan Vesely; Test that two stack objects are not stored in the same register 26723dcd6e0SJan Vesely; The second stack object should be in T3.X 26823dcd6e0SJan Vesely; FUNC-LABEL: {{^}}no_overlap: 26923dcd6e0SJan Vesely; R600_CHECK: MOV 27023dcd6e0SJan Vesely; R600_CHECK: [[CHAN:[XYZW]]]+ 27123dcd6e0SJan Vesely; R600-NOT: [[CHAN]]+ 27223dcd6e0SJan Vesely; SI: v_mov_b32_e32 v3 2738a028bf4SMatt Arsenaultdefine void @no_overlap(i32 addrspace(1)* %out, i32 %in) #0 { 27423dcd6e0SJan Veselyentry: 27523dcd6e0SJan Vesely %0 = alloca [3 x i8], align 1 27623dcd6e0SJan Vesely %1 = alloca [2 x i8], align 1 27723dcd6e0SJan Vesely %2 = getelementptr [3 x i8], [3 x i8]* %0, i32 0, i32 0 27823dcd6e0SJan Vesely %3 = getelementptr [3 x i8], [3 x i8]* %0, i32 0, i32 1 27923dcd6e0SJan Vesely %4 = getelementptr [3 x i8], [3 x i8]* %0, i32 0, i32 2 28023dcd6e0SJan Vesely %5 = getelementptr [2 x i8], [2 x i8]* %1, i32 0, i32 0 28123dcd6e0SJan Vesely %6 = getelementptr [2 x i8], [2 x i8]* %1, i32 0, i32 1 28223dcd6e0SJan Vesely store i8 0, i8* %2 28323dcd6e0SJan Vesely store i8 1, i8* %3 28423dcd6e0SJan Vesely store i8 2, i8* %4 28523dcd6e0SJan Vesely store i8 1, i8* %5 28623dcd6e0SJan Vesely store i8 0, i8* %6 28723dcd6e0SJan Vesely %7 = getelementptr [3 x i8], [3 x i8]* %0, i32 0, i32 %in 28823dcd6e0SJan Vesely %8 = getelementptr [2 x i8], [2 x i8]* %1, i32 0, i32 %in 28923dcd6e0SJan Vesely %9 = load i8, i8* %7 29023dcd6e0SJan Vesely %10 = load i8, i8* %8 29123dcd6e0SJan Vesely %11 = add i8 %9, %10 29223dcd6e0SJan Vesely %12 = sext i8 %11 to i32 29323dcd6e0SJan Vesely store i32 %12, i32 addrspace(1)* %out 29423dcd6e0SJan Vesely ret void 29523dcd6e0SJan Vesely} 29623dcd6e0SJan Vesely 2978a028bf4SMatt Arsenaultdefine void @char_array_array(i32 addrspace(1)* %out, i32 %index) #0 { 29823dcd6e0SJan Veselyentry: 29923dcd6e0SJan Vesely %alloca = alloca [2 x [2 x i8]] 30023dcd6e0SJan Vesely %gep0 = getelementptr [2 x [2 x i8]], [2 x [2 x i8]]* %alloca, i32 0, i32 0, i32 0 30123dcd6e0SJan Vesely %gep1 = getelementptr [2 x [2 x i8]], [2 x [2 x i8]]* %alloca, i32 0, i32 0, i32 1 30223dcd6e0SJan Vesely store i8 0, i8* %gep0 30323dcd6e0SJan Vesely store i8 1, i8* %gep1 30423dcd6e0SJan Vesely %gep2 = getelementptr [2 x [2 x i8]], [2 x [2 x i8]]* %alloca, i32 0, i32 0, i32 %index 30523dcd6e0SJan Vesely %load = load i8, i8* %gep2 30623dcd6e0SJan Vesely %sext = sext i8 %load to i32 30723dcd6e0SJan Vesely store i32 %sext, i32 addrspace(1)* %out 30823dcd6e0SJan Vesely ret void 30923dcd6e0SJan Vesely} 31023dcd6e0SJan Vesely 3118a028bf4SMatt Arsenaultdefine void @i32_array_array(i32 addrspace(1)* %out, i32 %index) #0 { 31223dcd6e0SJan Veselyentry: 31323dcd6e0SJan Vesely %alloca = alloca [2 x [2 x i32]] 31423dcd6e0SJan Vesely %gep0 = getelementptr [2 x [2 x i32]], [2 x [2 x i32]]* %alloca, i32 0, i32 0, i32 0 31523dcd6e0SJan Vesely %gep1 = getelementptr [2 x [2 x i32]], [2 x [2 x i32]]* %alloca, i32 0, i32 0, i32 1 31623dcd6e0SJan Vesely store i32 0, i32* %gep0 31723dcd6e0SJan Vesely store i32 1, i32* %gep1 31823dcd6e0SJan Vesely %gep2 = getelementptr [2 x [2 x i32]], [2 x [2 x i32]]* %alloca, i32 0, i32 0, i32 %index 31923dcd6e0SJan Vesely %load = load i32, i32* %gep2 32023dcd6e0SJan Vesely store i32 %load, i32 addrspace(1)* %out 32123dcd6e0SJan Vesely ret void 32223dcd6e0SJan Vesely} 32323dcd6e0SJan Vesely 3248a028bf4SMatt Arsenaultdefine void @i64_array_array(i64 addrspace(1)* %out, i32 %index) #0 { 32523dcd6e0SJan Veselyentry: 32623dcd6e0SJan Vesely %alloca = alloca [2 x [2 x i64]] 32723dcd6e0SJan Vesely %gep0 = getelementptr [2 x [2 x i64]], [2 x [2 x i64]]* %alloca, i32 0, i32 0, i32 0 32823dcd6e0SJan Vesely %gep1 = getelementptr [2 x [2 x i64]], [2 x [2 x i64]]* %alloca, i32 0, i32 0, i32 1 32923dcd6e0SJan Vesely store i64 0, i64* %gep0 33023dcd6e0SJan Vesely store i64 1, i64* %gep1 33123dcd6e0SJan Vesely %gep2 = getelementptr [2 x [2 x i64]], [2 x [2 x i64]]* %alloca, i32 0, i32 0, i32 %index 33223dcd6e0SJan Vesely %load = load i64, i64* %gep2 33323dcd6e0SJan Vesely store i64 %load, i64 addrspace(1)* %out 33423dcd6e0SJan Vesely ret void 33523dcd6e0SJan Vesely} 33623dcd6e0SJan Vesely 33723dcd6e0SJan Vesely%struct.pair32 = type { i32, i32 } 33823dcd6e0SJan Vesely 3398a028bf4SMatt Arsenaultdefine void @struct_array_array(i32 addrspace(1)* %out, i32 %index) #0 { 34023dcd6e0SJan Veselyentry: 34123dcd6e0SJan Vesely %alloca = alloca [2 x [2 x %struct.pair32]] 34223dcd6e0SJan Vesely %gep0 = getelementptr [2 x [2 x %struct.pair32]], [2 x [2 x %struct.pair32]]* %alloca, i32 0, i32 0, i32 0, i32 1 34323dcd6e0SJan Vesely %gep1 = getelementptr [2 x [2 x %struct.pair32]], [2 x [2 x %struct.pair32]]* %alloca, i32 0, i32 0, i32 1, i32 1 34423dcd6e0SJan Vesely store i32 0, i32* %gep0 34523dcd6e0SJan Vesely store i32 1, i32* %gep1 34623dcd6e0SJan Vesely %gep2 = getelementptr [2 x [2 x %struct.pair32]], [2 x [2 x %struct.pair32]]* %alloca, i32 0, i32 0, i32 %index, i32 0 34723dcd6e0SJan Vesely %load = load i32, i32* %gep2 34823dcd6e0SJan Vesely store i32 %load, i32 addrspace(1)* %out 34923dcd6e0SJan Vesely ret void 35023dcd6e0SJan Vesely} 35123dcd6e0SJan Vesely 3528a028bf4SMatt Arsenaultdefine void @struct_pair32_array(i32 addrspace(1)* %out, i32 %index) #0 { 35323dcd6e0SJan Veselyentry: 35423dcd6e0SJan Vesely %alloca = alloca [2 x %struct.pair32] 35523dcd6e0SJan Vesely %gep0 = getelementptr [2 x %struct.pair32], [2 x %struct.pair32]* %alloca, i32 0, i32 0, i32 1 35623dcd6e0SJan Vesely %gep1 = getelementptr [2 x %struct.pair32], [2 x %struct.pair32]* %alloca, i32 0, i32 1, i32 0 35723dcd6e0SJan Vesely store i32 0, i32* %gep0 35823dcd6e0SJan Vesely store i32 1, i32* %gep1 35923dcd6e0SJan Vesely %gep2 = getelementptr [2 x %struct.pair32], [2 x %struct.pair32]* %alloca, i32 0, i32 %index, i32 0 36023dcd6e0SJan Vesely %load = load i32, i32* %gep2 36123dcd6e0SJan Vesely store i32 %load, i32 addrspace(1)* %out 36223dcd6e0SJan Vesely ret void 36323dcd6e0SJan Vesely} 36423dcd6e0SJan Vesely 36523dcd6e0SJan Veselydefine void @select_private(i32 addrspace(1)* %out, i32 %in) nounwind { 36623dcd6e0SJan Veselyentry: 36723dcd6e0SJan Vesely %tmp = alloca [2 x i32] 36823dcd6e0SJan Vesely %tmp1 = getelementptr [2 x i32], [2 x i32]* %tmp, i32 0, i32 0 36923dcd6e0SJan Vesely %tmp2 = getelementptr [2 x i32], [2 x i32]* %tmp, i32 0, i32 1 37023dcd6e0SJan Vesely store i32 0, i32* %tmp1 37123dcd6e0SJan Vesely store i32 1, i32* %tmp2 37223dcd6e0SJan Vesely %cmp = icmp eq i32 %in, 0 37323dcd6e0SJan Vesely %sel = select i1 %cmp, i32* %tmp1, i32* %tmp2 37423dcd6e0SJan Vesely %load = load i32, i32* %sel 37523dcd6e0SJan Vesely store i32 %load, i32 addrspace(1)* %out 37623dcd6e0SJan Vesely ret void 37723dcd6e0SJan Vesely} 37823dcd6e0SJan Vesely 37923dcd6e0SJan Vesely; AMDGPUPromoteAlloca does not know how to handle ptrtoint. When it 38023dcd6e0SJan Vesely; finds one, it should stop trying to promote. 38123dcd6e0SJan Vesely 38223dcd6e0SJan Vesely; FUNC-LABEL: ptrtoint: 38323dcd6e0SJan Vesely; SI-NOT: ds_write 38423dcd6e0SJan Vesely; SI: buffer_store_dword v{{[0-9]+}}, v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}} offen 38523dcd6e0SJan Vesely; SI: buffer_load_dword v{{[0-9]+}}, v{{[0-9]+}}, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}} offen offset:5 ; 3868a028bf4SMatt Arsenaultdefine void @ptrtoint(i32 addrspace(1)* %out, i32 %a, i32 %b) #0 { 38723dcd6e0SJan Vesely %alloca = alloca [16 x i32] 38823dcd6e0SJan Vesely %tmp0 = getelementptr [16 x i32], [16 x i32]* %alloca, i32 0, i32 %a 38923dcd6e0SJan Vesely store i32 5, i32* %tmp0 39023dcd6e0SJan Vesely %tmp1 = ptrtoint [16 x i32]* %alloca to i32 39123dcd6e0SJan Vesely %tmp2 = add i32 %tmp1, 5 39223dcd6e0SJan Vesely %tmp3 = inttoptr i32 %tmp2 to i32* 39323dcd6e0SJan Vesely %tmp4 = getelementptr i32, i32* %tmp3, i32 %b 39423dcd6e0SJan Vesely %tmp5 = load i32, i32* %tmp4 39523dcd6e0SJan Vesely store i32 %tmp5, i32 addrspace(1)* %out 39623dcd6e0SJan Vesely ret void 39723dcd6e0SJan Vesely} 39823dcd6e0SJan Vesely 39923dcd6e0SJan Vesely; HSAOPT: !0 = !{} 40023dcd6e0SJan Vesely; HSAOPT: !1 = !{i32 0, i32 2048} 40123dcd6e0SJan Vesely 40223dcd6e0SJan Vesely; NOHSAOPT: !0 = !{i32 0, i32 2048} 4038a028bf4SMatt Arsenault 404*687ca8dfSJan Vesely 405*687ca8dfSJan Vesely; FUNC-LABEL: v16i32_stack: 406*687ca8dfSJan Vesely 407*687ca8dfSJan Vesely; R600: MOVA_INT 408*687ca8dfSJan Vesely; R600: MOVA_INT 409*687ca8dfSJan Vesely; R600: MOVA_INT 410*687ca8dfSJan Vesely; R600: MOVA_INT 411*687ca8dfSJan Vesely; R600: MOVA_INT 412*687ca8dfSJan Vesely; R600: MOVA_INT 413*687ca8dfSJan Vesely; R600: MOVA_INT 414*687ca8dfSJan Vesely; R600: MOVA_INT 415*687ca8dfSJan Vesely; R600: MOVA_INT 416*687ca8dfSJan Vesely; R600: MOVA_INT 417*687ca8dfSJan Vesely; R600: MOVA_INT 418*687ca8dfSJan Vesely; R600: MOVA_INT 419*687ca8dfSJan Vesely; R600: MOVA_INT 420*687ca8dfSJan Vesely; R600: MOVA_INT 421*687ca8dfSJan Vesely; R600: MOVA_INT 422*687ca8dfSJan Vesely; R600: MOVA_INT 423*687ca8dfSJan Vesely 424*687ca8dfSJan Vesely; SI: buffer_load_dword 425*687ca8dfSJan Vesely; SI: buffer_load_dword 426*687ca8dfSJan Vesely; SI: buffer_load_dword 427*687ca8dfSJan Vesely; SI: buffer_load_dword 428*687ca8dfSJan Vesely; SI: buffer_load_dword 429*687ca8dfSJan Vesely; SI: buffer_load_dword 430*687ca8dfSJan Vesely; SI: buffer_load_dword 431*687ca8dfSJan Vesely; SI: buffer_load_dword 432*687ca8dfSJan Vesely; SI: buffer_load_dword 433*687ca8dfSJan Vesely; SI: buffer_load_dword 434*687ca8dfSJan Vesely; SI: buffer_load_dword 435*687ca8dfSJan Vesely; SI: buffer_load_dword 436*687ca8dfSJan Vesely; SI: buffer_load_dword 437*687ca8dfSJan Vesely; SI: buffer_load_dword 438*687ca8dfSJan Vesely; SI: buffer_load_dword 439*687ca8dfSJan Vesely; SI: buffer_load_dword 440*687ca8dfSJan Vesely 441*687ca8dfSJan Veselydefine void @v16i32_stack(<16 x i32> addrspace(1)* %out, i32 %a) { 442*687ca8dfSJan Vesely %alloca = alloca [2 x <16 x i32>] 443*687ca8dfSJan Vesely %tmp0 = getelementptr [2 x <16 x i32>], [2 x <16 x i32>]* %alloca, i32 0, i32 %a 444*687ca8dfSJan Vesely %tmp5 = load <16 x i32>, <16 x i32>* %tmp0 445*687ca8dfSJan Vesely store <16 x i32> %tmp5, <16 x i32> addrspace(1)* %out 446*687ca8dfSJan Vesely ret void 447*687ca8dfSJan Vesely} 448*687ca8dfSJan Vesely 449*687ca8dfSJan Vesely; FUNC-LABEL: v16float_stack: 450*687ca8dfSJan Vesely 451*687ca8dfSJan Vesely; R600: MOVA_INT 452*687ca8dfSJan Vesely; R600: MOVA_INT 453*687ca8dfSJan Vesely; R600: MOVA_INT 454*687ca8dfSJan Vesely; R600: MOVA_INT 455*687ca8dfSJan Vesely; R600: MOVA_INT 456*687ca8dfSJan Vesely; R600: MOVA_INT 457*687ca8dfSJan Vesely; R600: MOVA_INT 458*687ca8dfSJan Vesely; R600: MOVA_INT 459*687ca8dfSJan Vesely; R600: MOVA_INT 460*687ca8dfSJan Vesely; R600: MOVA_INT 461*687ca8dfSJan Vesely; R600: MOVA_INT 462*687ca8dfSJan Vesely; R600: MOVA_INT 463*687ca8dfSJan Vesely; R600: MOVA_INT 464*687ca8dfSJan Vesely; R600: MOVA_INT 465*687ca8dfSJan Vesely; R600: MOVA_INT 466*687ca8dfSJan Vesely; R600: MOVA_INT 467*687ca8dfSJan Vesely 468*687ca8dfSJan Vesely; SI: buffer_load_dword 469*687ca8dfSJan Vesely; SI: buffer_load_dword 470*687ca8dfSJan Vesely; SI: buffer_load_dword 471*687ca8dfSJan Vesely; SI: buffer_load_dword 472*687ca8dfSJan Vesely; SI: buffer_load_dword 473*687ca8dfSJan Vesely; SI: buffer_load_dword 474*687ca8dfSJan Vesely; SI: buffer_load_dword 475*687ca8dfSJan Vesely; SI: buffer_load_dword 476*687ca8dfSJan Vesely; SI: buffer_load_dword 477*687ca8dfSJan Vesely; SI: buffer_load_dword 478*687ca8dfSJan Vesely; SI: buffer_load_dword 479*687ca8dfSJan Vesely; SI: buffer_load_dword 480*687ca8dfSJan Vesely; SI: buffer_load_dword 481*687ca8dfSJan Vesely; SI: buffer_load_dword 482*687ca8dfSJan Vesely; SI: buffer_load_dword 483*687ca8dfSJan Vesely; SI: buffer_load_dword 484*687ca8dfSJan Vesely 485*687ca8dfSJan Veselydefine void @v16float_stack(<16 x float> addrspace(1)* %out, i32 %a) { 486*687ca8dfSJan Vesely %alloca = alloca [2 x <16 x float>] 487*687ca8dfSJan Vesely %tmp0 = getelementptr [2 x <16 x float>], [2 x <16 x float>]* %alloca, i32 0, i32 %a 488*687ca8dfSJan Vesely %tmp5 = load <16 x float>, <16 x float>* %tmp0 489*687ca8dfSJan Vesely store <16 x float> %tmp5, <16 x float> addrspace(1)* %out 490*687ca8dfSJan Vesely ret void 491*687ca8dfSJan Vesely} 492*687ca8dfSJan Vesely 493*687ca8dfSJan Vesely; FUNC-LABEL: v2float_stack: 494*687ca8dfSJan Vesely 495*687ca8dfSJan Vesely; R600: MOVA_INT 496*687ca8dfSJan Vesely; R600: MOVA_INT 497*687ca8dfSJan Vesely 498*687ca8dfSJan Vesely; SI: buffer_load_dword 499*687ca8dfSJan Vesely; SI: buffer_load_dword 500*687ca8dfSJan Vesely 501*687ca8dfSJan Veselydefine void @v2float_stack(<2 x float> addrspace(1)* %out, i32 %a) { 502*687ca8dfSJan Vesely %alloca = alloca [16 x <2 x float>] 503*687ca8dfSJan Vesely %tmp0 = getelementptr [16 x <2 x float>], [16 x <2 x float>]* %alloca, i32 0, i32 %a 504*687ca8dfSJan Vesely %tmp5 = load <2 x float>, <2 x float>* %tmp0 505*687ca8dfSJan Vesely store <2 x float> %tmp5, <2 x float> addrspace(1)* %out 506*687ca8dfSJan Vesely ret void 507*687ca8dfSJan Vesely} 508*687ca8dfSJan Vesely 5098a028bf4SMatt Arsenaultattributes #0 = { nounwind "amdgpu-max-waves-per-eu"="2" } 510